Exam 11: Inheritance

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

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 }

Free
(Multiple Choice)
4.8/5
(34)
Correct Answer:
Verified

C

If ClassA extends ClassB,then

Free
(Multiple Choice)
4.8/5
(37)
Correct Answer:
Verified

B

When an "is a" relationship exists between objects,it means that the specialized object has

Free
(Multiple Choice)
4.8/5
(39)
Correct Answer:
Verified

D

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 method1 will be executed when the following statements are executed? ClassA item1 = new ClassB(); Item1.method1();

(Multiple Choice)
4.8/5
(39)

If a class contains an abstract method,

(Multiple Choice)
4.7/5
(34)

Look at the following code and determine what the call to super will do. public class ClassB extends ClassA { Public ClassB() { Super(10); } }

(Multiple Choice)
4.9/5
(42)

If two methods in the same class have the same name but different signatures,the second overrides the first.

(True/False)
4.9/5
(37)

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

(Multiple Choice)
5.0/5
(33)

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.

(True/False)
4.8/5
(32)

In UML diagrams,inheritance is shown

(Multiple Choice)
4.8/5
(39)

A subclass can directly access

(Multiple Choice)
4.8/5
(41)

Every class is either directly or indirectly derived from the Object class.

(True/False)
4.9/5
(40)

Which of the following is true about protected access?

(Multiple Choice)
4.8/5
(37)

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.8/5
(31)

An abstract class is not instantiated,but serves as a superclass for other classes.

(True/False)
4.9/5
(37)

Protected class members are denoted in a UML diagram with the symbol

(Multiple Choice)
4.9/5
(31)

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

(Multiple Choice)
5.0/5
(35)

In the following code,what will the call to super do? public class ClassB extends ClassA { Public ClassB() { Super(40); System.out.println("This is the last statement "+ "in the constructor."); } }

(Multiple Choice)
4.8/5
(33)

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

(Multiple Choice)
4.9/5
(36)

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 as a result of the following statements? ClassB item1 = new ClassA(); Item1.method1();

(Multiple Choice)
4.9/5
(33)
Showing 1 - 20 of 49
close modal

Filters

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