Filters
Question type

Study Flashcards

If a superclass does not have a default constructor or a no-arg constructor:


A) then a class that inherits from it, must initialize the superclass values.
B) then a class that inherits from it, must call one of the constructors that the superclass does have.
C) then a class that inherits from it, does not inherit the data member fields from the superclass.
D) then a class that inherits from it, must contain the default constructor for the superclass.

Correct Answer

verifed

verified

If a subclass constructor does not explicitly call a superclass constructor:


A) it must include the code necessary to initialize the superclass fields
B) the superclass fields will be set to the default values for their data types
C) Java will automatically call the superclass's default or no-arg constructor immediately after the code in the subclass's constructor executes
D) Java will automatically call the superclass's default or no-arg constructor just before the code in the subclass's constructor executes

Correct Answer

verifed

verified

When a subclass extends a superclass, the public members of the superclass become public members of the subclass.

Correct Answer

verifed

verified

What is required for an interface method that has a body?


A) The method header must begin with the key word default.
B) A class that implements the interface must override the method.
C) The @Default annotation must precede the method header.
D) All of the above

Correct Answer

verifed

verified

When declaring class data members, it is best to declare them as:


A) private members
B) public members
C) protected members
D) restricted members

Correct Answer

verifed

verified

Look at the following code. Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public void method1() {} Line 5 } Line 6 public class ClassB extends ClassA Line 7 { Line 8 public ClassB() {} Line 9 public void method1() {} Line 10 } Line 11 public class ClassC extends ClassB Line 12 { Line 13 public ClassC() {} Line 14 public void method1() {} Line 15 } Which method1 will be executed as a result of the following statements? ClassA item1 = new ClassC() ; Item1.method1() ;


A) Line 4
B) Line 9
C) Line 14
D) This is an error and will cause the program to crash.

Correct Answer

verifed

verified

All methods in an abstract class must also be declared abstract.

Correct Answer

verifed

verified

When an interface variable references an object, you can use the interface variable to call any and all of the methods in the class implementing the interface.

Correct Answer

verifed

verified

Look at the following code. Which line will cause a compiler error? Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public final int method1(int a) {} Line 5 public double method2(int b) {} Line 6 } Line 7 public ClassB extends ClassA Line 8 { Line 9 public ClassB() {} Line 10 public int method1(int b) {} Line 11 public double method2(double c) {} Line 12 }


A) 4
B) 5
C) 10
D) 11

Correct Answer

verifed

verified

If two methods have the same name but different signatures, they are:


A) overridden
B) overloaded
C) superclass methods
D) subclass methods

Correct Answer

verifed

verified

Showing 61 - 70 of 70

Related Exams

Show Answer