Ch8 Quiz review Flashcards

0
Q

The ____ of a class are called the members of a class.

A

Components

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
1
Q

T/F

Finalizers are value-returning methods that return the final value of a variable.

A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q
T/F
Members of a class consist of packages, methods, and libraries.
A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

T/F

You can import your classes the same way you import Java classes.

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Which of the following set of statements are valid in Java?

(i) bigRect.area();
bigRect.perimeter();
bigRect.print();

(ii) bigRect.area = bigRect.area();
bigRect.perimeter = bigRect.perimeter();
bigRect.print();

A

Only (i)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you declare a new reference variable of the type Illustrate and instantiate the object with a value of 9?

A

Illustrate illObject = new Illustrate(9);

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the function of the reserved word class?

A

It defines only a data type / does not allocate memory

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q
T/F
An accessor method of a class first accesses the values of the data members of the class and then changes the value of the data members.
A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

In ___ copying, each reference variable refers to its own object.

A

Deep

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

T/F

In shallow copying, each reference variable refers to its own object.

A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q
T/F
The method finalize automatically executes when the class object goes out of scope.
A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Which statement correctly instantiates the Rectangle object myRectangle?

(i) myRectangle Rectangle = new Rectangle (10,12);
(ii) class myRectangle = new Rectangle (10,12);
(iii) Rectangle myRectangle = new Rectangle (10,12);

A

Only (iii)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

T/F
The following statement is legal:
aa.print();

A

TRUE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the main use of inner classes?

A

To handle events

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q
T/F
The components of a class are called fields.
A

FALSE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

T/F

Modifiers are used to altar the behavior of the class.

A

TRUE

16
Q

When does the method finalize execute?

A

When the class object goes out of scope

17
Q

Which of the following statements are valid in Java?

(i) r = console.nextDouble();
myCircle.area = 3.14 * r * r;
System.out.println(myCircle.area);

(ii) r = console.nextDouble();
myCircle.set(r);
System.out.println(myCircle.area);

A

Only ii

18
Q

What is a constructor without parameters?

A

Default constructor

19
Q

T/F

The built in operation that is valid for classes is the dot (.) operator

A

TRUE

20
Q

What does the constructor do in the class definition above? //missing info above

A

Sets value of X to 1

21
Q
T/F
If a class method is used to implement a binary operation on the class objects; then the method must have two parameters of the class type.
A

FALSE

22
Q

T/F
The following statement is legal:
aa.x = 10;

A

FALSE

23
Q
Which of the following statements is illegal?
//missing info
A

Illustrate.x++;

24
Q

Which of the following statements are valid in Java?

(i) bigRect.set(10, 5};

(ii) bigRect.length = 10;
bigRect.width = 5;

A

Only (i)

25
Q
T/F
A class and its members can be described graphically using Unified Modeling Language (UML) notation.
A

TRUE

26
Q

T/F

If the object is created in a user program, then the object can access both the public and private members of the class.

A

FALSE

27
Q
T/F 
When no object of the class type is instantiated static data members of the class fail to exist.
A

FALSE

28
Q

Which of the following statements are valid in Java?

(i) person2 = person1;

(ii) n = person1.getName();
    a = person1.getAge();
    h = person1.getHeight();
    w = person1.getWeight();
    person2.set(n, a, h, w);
A

Both (i) and (ii)

29
Q
T/F
If a member of a class is public you cannot access it outside the class.
A

FALSE

30
Q
T/F
If a member of a class is a method, it can directly access any member of the class.
A

TRUE

31
Q

T/F

A constructor has the same name as the class.

A

TRUE

32
Q

T/F

You cannot override the default definition of the method: toString because it’s provided by Java.

A

FALSE

33
Q

Which of the following words indicates an object’s reference to itself?

A

This

34
Q
T/F
A class can have only one constructor.
A

FALSE