Filters
Question type

Study Flashcards

For the questions below, consider the following class definition: public class AClass { protected int x; protected int y; public AClass(int a, int b) { x = a; y = b; } public int addEm( ) { return x + y; } public void changeEm( ) { x++; y--; } public String toString( ) { return "" + x + " " + y; } } -Consider that you want to extend AClass to BClass. BClass will have a third int instance data, z. Which of the following would best define BClass'constructor?


A) public BClass(int a, int b, int c) {
Super(a, b, c) ;
}
B) public BClass(int a, int b, int c) {
X = a;
Y = b;
Z = c;
}
C) public BClass(int a, int b, int c) {
Z = c;
}
D) public BClass(int a, int b, int c) {
Super(a, b) ;
Z = c;
}
E) public BClass(int a, int b, int c) {
Super( ) ;
}

F) C) and D)
G) B) and D)

Correct Answer

verifed

verified

Which of the following is not a method of the Object class?


A) clone
B) compareTo
C) equals
D) toString
E) all of the above are methods of the Object class

F) A) and D)
G) A) and C)

Correct Answer

verifed

verified

If A, B, Y and Z all contain the same instance data d1, then d1 should be declared in X and inherited into Y, Z, A and B.

A) True
B) False

Correct Answer

verifed

verified

Using the reserved word, super, one can


A) access a parent class'constructor(s)
B) access a parent class'methods and instance data
C) access a child class'constructor(s)
D) access a child class'methods and instance data
E) none of the above

F) A) and E)
G) D) and E)

Correct Answer

verifed

verified

Two children of the same parent class are known as


A) aliases
B) relatives
C) clones
D) brothers
E) siblings

F) C) and E)
G) C) and D)

Correct Answer

verifed

verified

Explain the difference between implementing an interface and a derived class.

Correct Answer

verifed

verified

Implementing an interface means that you...

View Answer

A motorcycle inherits properties from both a bicycle and a car. Java does not permit multiple inheritance. Assume that Bicycle and Car have both been declared. Explain how you might go about implementing a Motorcycle as a derived class.

Correct Answer

verifed

verified

You should extend whichever class is clo...

View Answer

Inheritance through an extended (derived) class supports which of the following concepts?


A) interfaces
B) modulary
C) information hiding
D) code reuse
E) correctness

F) A) and E)
G) A) and B)

Correct Answer

verifed

verified

In what manners are Timer objects similar to and different from other GUI components?

Correct Answer

verifed

verified

Timer objects are declared within the ja...

View Answer

What methods inherited from Car should SportsCar override?

Correct Answer

verifed

verified

Because a SportsCar will have different ...

View Answer

The reserved word, extends, is used to denote a has-a relationship.

A) True
B) False

Correct Answer

verifed

verified

Showing 61 - 71 of 71

Related Exams

Show Answer