Exam 10: Introduction to Inheritance

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

You cannot declare a class to be final .

(True/False)
4.9/5
(27)

public HourlyEmployee(char dept, double rate, int hours) { ​      ---- code here ---- ​ } ​Given the overloaded constructor above, write the appropriate statement that calls the superclass constructor  and passes the indicated arguments to the superclass constructor.

(Essay)
4.8/5
(37)

class InstanceofDemo {     public static void main(String[] args)    {         Parent object1 = new Parent();         Parent object2 = new Child();         System.out.println("object1 instanceof Parent: "             + (obj1 instanceof Parent));         System.out.println("object1 instanceof Child: "             + (obj1 instanceof Child));         System.out.println("object1 instanceof MyInterface: "             + (obj1 instanceof MyInterface));         System.out.println("object2 instanceof Parent: "             + (obj2 instanceof Parent));         System.out.println("object2 instanceof Child: "             + (obj2 instanceof Child));         System.out.println("object2 instanceof MyInterface: "             + (obj2 instanceof MyInterface));      } } The above code defines a parent class (named Parent ), a simple interface (named MyInterface ), and a child class (named Child ) that inherits from the parent and implements the interface. Following program execution, what will be the output of the six println statements?

(Essay)
5.0/5
(35)

You use the keyword ____ to achieve inheritance in Java.

(Multiple Choice)
4.8/5
(33)

  Use the above code and sections labeled 1, 2, and 3 to answer the following:  Identify the labeled section that is the constructor for the Bicycle class, identify the section of fields of the Bicycle class, and identify the Bicycle class methods. Use the above code and sections labeled 1, 2, and 3 to answer the following: Identify the labeled section that is the constructor for the Bicycle class, identify the section of fields of the Bicycle class, and identify the Bicycle class methods.

(Essay)
4.8/5
(39)

What are virtual method calls?

(Essay)
4.8/5
(40)

​ public class ASuperClass {    public ASuperClass()    {       System.out.println("In superclass constructor");    } } public class ASubClass extends ASuperClass {    public ASubClass()    {       System.out.println("In subclass constructor");    } } public class DemoConstructors {    public static void main(String[] args)    {       ASubClass child = new ASubClass();    } } ​ Given the above code, what will the output be when DemoConstructors executes?

(Essay)
4.7/5
(33)

Write the statement to create a class header with a superclass-subclass relationship, with Vehicle as the superclass and Subaru as the subclass.

(Essay)
4.9/5
(37)

The methods in a subclass can use all of the data fields and methods that belong to its parent, with one exception: ____ members of the parent class are not accessible within a child class's methods.

(Multiple Choice)
4.9/5
(29)

If jrStudent is an object of Student , which of the following statements will result in a value of true ?

(Multiple Choice)
4.8/5
(44)
Match each term with the correct statement below.
Premises:
Specific type of containment
Responses:
virtual method call
superclass
inheritance
Correct Answer:
Verified
Premises:
Responses:
Specific type of containment
virtual method call
(Matching)
4.9/5
(40)
Match each term with the correct statement below.
Premises:
Keeps data private
Responses:
class diagram
superclass
instanceof
Correct Answer:
Verified
Premises:
Responses:
Keeps data private
class diagram
(Matching)
4.9/5
(32)

Programmers and analysts sometimes use a graphical language to describe classes and object-oriented processes. This language is called ____.

(Multiple Choice)
4.7/5
(34)

You can use the ____ modifier with methods when you don't want the method to be overridden.

(Multiple Choice)
4.8/5
(25)
Match each term with the correct statement below.
Premises:
A base class
Responses:
super()
inlining
superclass
Correct Answer:
Verified
Premises:
Responses:
A base class
super()
(Matching)
4.8/5
(33)

    Will the above code compile correctly? Why or why not? Explain your answer.     Will the above code compile correctly? Why or why not? Explain your answer. Will the above code compile correctly? Why or why not? Explain your answer.

(Essay)
4.8/5
(40)

  The UML diagram above derives a subclass called EmployeeWithTerritory from the superclass Employee . Describe what variables and methods the class EmployeeWithTerritory  inherits from the superclass Employee. Also, describe any variables and public methods defined by the subclass EmployeeWithTerritory . The UML diagram above derives a subclass called EmployeeWithTerritory from the superclass Employee . Describe what variables and methods the class EmployeeWithTerritory  inherits from the superclass Employee. Also, describe any variables and public methods defined by the subclass EmployeeWithTerritory .

(Essay)
4.9/5
(35)

In most Java classes, the keywo rd ____ precedes each data field, and the keyword ____ precedes each method.

(Multiple Choice)
4.8/5
(45)

When you create a class by making it inherit from another class, the new class automatically contains the data fields and _____ of the original class.

(Multiple Choice)
4.9/5
(36)

class Vehicle {} public class Car extends Vehicle {    public static void main(String args[])    {       Vehicle myCar = new Car();       boolean result =  myCar instanceof Car;       System.out.println(result);    } } The above code uses the instanceof operator to determine whether an object is a member of a class. What will be the output following execution?

(Essay)
4.8/5
(39)
Showing 41 - 60 of 78
close modal

Filters

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