StaticTest2.java Questions
Instructions
- With the left mouse button pressed, drag the mouse
across the contents of the program listing that is shown
below. This will select the program listing. Then
choose Copy from the Edit menu of your web
browser to copy the program listing to the clipboard.
- Start your text editor and create a new file called
StaticTest2.java. Choose Paste to paste the contents of
the program listing from the clipboard into the new file.
- Save the file to disk and begin answering the
questions that are shown below.
- When you need to look at the model answer, click here.
- Click here to go back to the
tutorials menu.
Program listing
|
class Character {
public String name;
public String favouriteColour;
public int favouriteNumber;
public Character(String aName, String aColour, int aNumber)
{
name = aName;
favouriteColour = aColour;
favouriteNumber = aNumber;
}
public void displayMe()
{
System.out.println("Hello, my name is " + name);
System.out.println("my favourite colour is " + favouriteColour);
System.out.println("and my favourite number is " + favouriteNumber);
}
}
class StaticTest2
{
public static void main(String[] args)
{
Character f = new Character("Fred Flintstone", "blue", 42);
}
}