Exam 10: Introduction to Inheritance
Exam 1: Creating Your First Java Classes76 Questions
Exam 2: Using Data81 Questions
Exam 3: Using Methods, Classes and Objects79 Questions
Exam 4: More Object Concepts84 Questions
Exam 5: Making Decisions80 Questions
Exam 6: Looping77 Questions
Exam 7: Characters, Strings and the Stringbuilder82 Questions
Exam 8: Arrays77 Questions
Exam 9: Advanced Array Concepts80 Questions
Exam 10: Introduction to Inheritance78 Questions
Exam 11: Advanced Inheritance Concepts78 Questions
Exam 12: Exception Handling79 Questions
Exam 13: File Input and Output78 Questions
Exam 14: Introduction to Swing Components79 Questions
Exam 15: Using Javafx and Scene Builder65 Questions
Select questions type
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)
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)
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:
Premises:
Responses:
(Matching)
4.9/5
(40)
Match each term with the correct statement below.
Premises:
Keeps data private
Responses:
class diagram
superclass
instanceof
Correct Answer:
Premises:
Responses:
(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:
Premises:
Responses:
(Matching)
4.8/5
(33)
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 .

(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
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)