The BASE for JAVA LEARNING
by
PRO
FE S
S OR

QUIZ for SECTION V
To find an answer, click on the desired question.
QUESTION 1: What is a class ? What is it used for ?
QUESTION 2: What is an Object ? What are the characteristics of an Object ?
QUESTION 3: What's the keyword to instantiate a class (create an Object) ?
QUESTION 4: Can we create more than one Object from a class ?
QUESTION 5: Convert the following 2 lines of code into only 1 line of code.
Quiz test ;
test = new Quiz();
QUESTION 6: There are 3 lines of code in program below that are used to display a local variable,
a class variable(static), and an instance variable (an Object variable). Substitute the XXX, YYY, and ZZZ, for
the required expressions to display those variables.
class Quiz
{
static double amount = 21.46;
int number;
public static void main(String[] args)
{
int number = 45;
Quiz test = new Quiz(); // Quiz class is instantiated
System.out.println( XXX ); // displays local variable number 45
System.out.println( YYY ); // displays the class variable amount 21.46
System.out.println( ZZZ ); // displays the instance variable number 0 of the Quiz class
}
}
}
Click your Back Button on your Browser to go back to the QUIZ Section.
ANSWER to QUESTION 1: A class is a template, a blueprint for Objects.
A class is instantiated to create an Object. It accomplishes ENCAPSULATION.
Click your Back Button on your Browser to go back to the QUIZ Section.
ANSWER to QUESTION 2: An Object is an entity, which is an instance of a class.
An Object has:
- Relationship -> It may interact with other Objects
- Identity -> It's unique
- Behavior -> contains methods
- State -> it's initialized
Click your Back Button on your Browser to go back to the QUIZ Section.
ANSWER to QUESTION 3: Keyword: new
Click your Back Button on your Browser to go back to the QUIZ Section.
ANSWER to QUESTION 4: Yes.
A class can be instantiated several times, creating
a different object each time.
Click your Back Button on your Browser to go back to the QUIZ Section.
ANSWER to QUESTION 5: Quiz test = new Quiz();
Click your Back Button on your Browser to go back to the QUIZ Section.
ANSWER to QUESTION 6: XXX -> substitute for number
YYY -> substitute for amount or for Quiz.amount
ZZZ -> substitute for test.number
Click your Back Button on your Browser to go back to the QUIZ Section.
Click here to go to the JAVA Mini-Course page