Filters
Question type

Study Flashcards

An abstract class ____.


A) does not have any subclasses
B) is a superclass with many subclasses
C) cannot be instantiated
D) is the base class of all other classes

E) C) and D)
F) A) and D)

Correct Answer

verifed

verified

Which operator is used to determine if an object is of a particular class type?


A) The operator new
B) The dot (.) operator
C) The instanceof operator
D) The + operator

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

In Java, you can automatically make a reference variable of a subclass type point to an object of its superclass.

A) True
B) False

Correct Answer

verifed

verified

Redefining a method of a superclass is also known as overloading a method.

A) True
B) False

Correct Answer

verifed

verified

In dynamic binding, the method that gets executed is determined at compile time, not at execution time.

A) True
B) False

Correct Answer

verifed

verified

An interface is a class that contains only abstract methods and/or named constants.

A) True
B) False

Correct Answer

verifed

verified

Which of the following statements about the reference super is true?


A) It must be used every time a method from the superclass is called.
B) It must be the last statement of the subclass constructor.
C) It must be the first statement of the subclass constructor.
D) It can only be used once in a program.

E) None of the above
F) B) and D)

Correct Answer

verifed

verified

Suppose there are three classes named Shape, Circle, and Square. What is the most likely relationship between them?


A) Square is a superclass, and Shape and Circle are subclasses of Square.
B) Shape is a superclass, and Circle and Square are subclasses of Shape.
C) Shape, Circle, and Square are all sibling classes.
D) These three classes cannot be related.

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

Inheritance implies an "is-a" relationship.

A) True
B) False

Correct Answer

verifed

verified

Java uses late binding for methods that are private but not for methods that are marked final.

A) True
B) False

Correct Answer

verifed

verified

A polymorphic reference variable can refer to either an object of its own class or an object of the subclasses inherited from its class.

A) True
B) False

Correct Answer

verifed

verified

Consider the following class definitions. public class BClass {private int x; public void set(int a) { x = a; } public void print() { }} public class DClass extends BClass {private int y; public void set(int a, int b) {//Postcondition: x = a; y = b;} public void print() { }} Which of the following is the correct definition of the method set of the class DClass? (i) public void set(int a, int b) {super.set(a) ; y = b;} (ii) public void set(int a, int b) {x = a; y = b;}


A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) None of these

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

  -Based on the diagram in the accompanying figure, the method setDimension in the class Box ____ the method setDimension in the class Rectangle. A)  overloads B)  overrides C)  overstates D)  deletes -Based on the diagram in the accompanying figure, the method setDimension in the class Box ____ the method setDimension in the class Rectangle.


A) overloads
B) overrides
C) overstates
D) deletes

E) B) and D)
F) B) and C)

Correct Answer

verifed

verified

Inheritance is an example of what type of relationship?


A) is-a
B) has-a
C) was-a
D) had-a

E) A) and D)
F) B) and D)

Correct Answer

verifed

verified

Composition is also called ____.


A) inheritance
B) aggregation
C) overloading
D) overriding

E) None of the above
F) A) and D)

Correct Answer

verifed

verified

A subclass cannot directly access public members of a superclass.

A) True
B) False

Correct Answer

verifed

verified

  -Based on the diagram in the accompanying figure, the method area in the class Box ____ the method area in the class Rectangle. A)  overloads B)  overrides C)  overstates D)  deletes -Based on the diagram in the accompanying figure, the method area in the class Box ____ the method area in the class Rectangle.


A) overloads
B) overrides
C) overstates
D) deletes

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

Suppose that the class Mystery is derived from the class Secret. Consider the following statements. Secret secRef = new Secret() ; Mystery mysRef = new Mystery() ; Which of the following statements is legal in Java? (i) secRef = mysRef; (ii) mysRef = secRef;


A) Only (i)
B) Only (ii)
C) Both (i) and (ii)
D) None of these

E) All of the above
F) None of the above

Correct Answer

verifed

verified

Consider the following class definitions. public class BClass {private int x; private double y; public void print() { }} public class DClass extends BClass {private int a; private int b; public void print() { }} Suppose that you have the following statement. DClass dObject = new DClass() ; How many instance variables does dObject have?


A) zero
B) two
C) three
D) four

E) None of the above
F) A) and B)

Correct Answer

verifed

verified

An abstract method ____.


A) is any method in the abstract class
B) cannot be inherited
C) has no body
D) is found in a subclass and overrides methods in a superclass using the reserved word abstract

E) C) and D)
F) A) and C)

Correct Answer

verifed

verified

Showing 21 - 40 of 50

Related Exams

Show Answer