Exam 10: Inheritance

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

If you do not provide an access specifier for a class member, the class member is given ________ by default.

(Multiple Choice)
4.8/5
(83)

In an inheritance relationship, the subclass constructor always executes before the superclass constructor.

(True/False)
4.9/5
(91)

If ClassA extends ClassB, then:

(Multiple Choice)
4.9/5
(76)

In the following statement, which is the interface? Public class ClassA extends ClassB implements ClassC

(Multiple Choice)
4.8/5
(67)

Given the following code which of the following is TRUE? Public class ClassB implements ClassA{}

(Multiple Choice)
4.8/5
(69)

Look at the following code. Which line has an error? Line 1 public interface Interface1 Line 2 { Line 3 int FIELDA = 55; Line 4 public int methodA(double){} Line 5 }

(Multiple Choice)
4.7/5
(82)

When a method is declared with the ________ modifier, it cannot be overridden in a subclass.

(Multiple Choice)
4.8/5
(75)

In an interface all methods have:

(Multiple Choice)
4.9/5
(83)

In a class hierarchy:

(Multiple Choice)
4.9/5
(84)

A subclass may call an overridden superclass method by:

(Multiple Choice)
4.9/5
(76)

Look at the following code: Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public void method1(int a){} 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 method will be executed when the following statements are executed? ClassC item1 = new ClassA(); Item1.method1();

(Multiple Choice)
4.8/5
(77)

This is a variable whose value is never changed, but it isn't declared with the final key word.

(Multiple Choice)
4.8/5
(92)

Look at the following code. The method in line ________ will override the method in line ________. Line 1 public class ClassA Line 2 { Line 3 public ClassA() {} Line 4 public int method1(int a){} Line 5 public int 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 int method2(double c){} Line 12 }

(Multiple Choice)
4.9/5
(87)

Which of the following is TRUE about protected access?

(Multiple Choice)
4.9/5
(81)

Look at the following code. What is missing from ClassA? Line 1 public interface MyInterface Line 2 { Line 3 int FIELDA = 55; Line 4 public int methodA(double); Line 5 } Line 6 public class ClassA implements MyInterface Line 7 { Line 8 FIELDA = 60; Line 9 public int methodB(double) { } Line 10 }

(Multiple Choice)
5.0/5
(82)

What is wrong with the following code? IntCalculator square = new IntCalculator() { Public int calculate(int number) { Return number * number; }}

(Multiple Choice)
4.8/5
(74)

In the following statement, which is the subclass? Public class ClassA extends ClassB implements ClassC

(Multiple Choice)
4.9/5
(77)

Inheritance involves a subclass, which is the general class, and a superclass, which is the specialized class.

(True/False)
4.8/5
(67)

If ClassC extends ClassB, which extends ClassA, this would be an example of:

(Multiple Choice)
4.7/5
(79)

What key word can you use to call a superclass constructor explicitly?

(Multiple Choice)
4.8/5
(89)
Showing 21 - 40 of 70
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)