Exam 9: Inheritance
Exam 1: Introduction98 Questions
Exam 2: Using Objects76 Questions
Exam 3: Implementing Classes103 Questions
Exam 4: Fundamental Data Types125 Questions
Exam 5: Decisions120 Questions
Exam 6: Loops128 Questions
Exam 7: Arrays and Array Lists118 Questions
Exam 8: Designing Classes95 Questions
Exam 9: Inheritance101 Questions
Exam 10: Interfaces85 Questions
Exam 11: Inputoutput and Exception Handling109 Questions
Exam 12: Object-Oriented Design104 Questions
Exam 13: Recursion110 Questions
Exam 14: Sorting and Searching109 Questions
Exam 15: The Java Collections Framework110 Questions
Exam 16: Basic Data Structures104 Questions
Exam 17: Tree Structures110 Questions
Exam 18: Generic Classes75 Questions
Exam 19: Graphical User Interfaces76 Questions
Exam 20: Streams and Binary Inputoutput82 Questions
Exam 21: Multithreading82 Questions
Exam 22: Internet Networking74 Questions
Exam 23: Relational Databases75 Questions
Exam 24: XML74 Questions
Exam 25: Web Applications75 Questions
Select questions type
Consider the following code snippet: public class Employee
{
) . .
Public void setDepartment(String deptName)
{
) . .
}
}
Public class Programmer extends Employee
{
) . .
Public void setProjectName(String projName)
{
) . .
}
Public void setDepartment(String deptName)
{
) . .
}
}
Which of the following statements is NOT correct?
(Multiple Choice)
4.7/5
(30)
Consider the following code snippet: public class Motorcycle extends Vehicle
{
) . .
Public Motorcycle(int numberAxles)
{
Super.numberAxles;
}
}
What does this code do?
(Multiple Choice)
4.8/5
(31)
You are creating a Motorcycle class that is supposed to be a subclass of the Vehicle class. Which of the following class declaration statements will accomplish this?
(Multiple Choice)
4.8/5
(47)
To override a superclass method in a subclass, the subclass method ____.
(Multiple Choice)
4.8/5
(38)
Consider the following code snippet: public class Vehicle
{
Protected int numberAxles;
) . .
}
Data in the numberAxles variable can be accessed by ____.
(Multiple Choice)
4.8/5
(37)
Which of the following statements about abstract methods is true?
(Multiple Choice)
4.7/5
(34)
Consider the following code snippet: public class Motorcycle extends Vehicle
{
) . .
Public Motorcycle(int numberAxles)
{
Super(numberAxles); //line #1
}
}
If the line marked "//line #1" was missing, which of these statements would be correct?
(Multiple Choice)
4.8/5
(43)
Consider the following code snippet: public class Coin
{
Private String name;
) . .
Public boolean equals(Object otherCoin)
{
Return name.equals(otherCoin.name);
}
) . .
}
What is wrong with this code?
(Multiple Choice)
4.8/5
(38)
You are creating a Motorcycle class which is supposed to be a subclass of the Vehicle class. Which of the following class declaration statements will accomplish this?
(Multiple Choice)
4.8/5
(34)
Which of the following statements about comparing objects is correct?
(Multiple Choice)
4.8/5
(37)
Consider the following code snippet of a function object public interface Measurer
{
Double measure(______ anObject);
}
Complete this code to allow the interface to handle all classes?
(Multiple Choice)
4.8/5
(36)
When declared as protected, data in an object can be accessed by ____.
(Multiple Choice)
4.9/5
(35)
All hamsters are rodents and all rodents are mammals. What hierarchy best captures this information?
(Multiple Choice)
4.9/5
(36)
Consider the classes shown below: public class Parent
{
Public void doSomething(){/* Implementation not shown */}
}
Public class Child extends Parent
{
Public void doAnotherThing(){/* Implementation not shown */}
}
Which lines in the following code will compile without error?
Parent kid = new Child();
Kid)doSomething(); // line 1
Kid)doAnotherThing(); // line 2
(Multiple Choice)
4.9/5
(37)
Consider the following code snippet: public abstract class Employee
{
Public abstract void setSalary();
) . .
}
You wish to create a concrete subclass named Programmer. Which of the following is the correct way to declare this subclass?
(Multiple Choice)
4.7/5
(42)
A class that represents a more specific entity in an inheritance hierarchy is called a/an ____.
(Multiple Choice)
4.8/5
(31)
Consider the classes shown below: public class Parent
{
Public void doSomething() // method 1
{ /* Implementation not shown */ }
}
Public class Child extends Parent {
Public void doSomething(int n) // method 2
{ /* Implementation not shown */ }
Public void doSomething() // method 3
{ /* Implementation not shown */ }
}
If the variable kid is defined below, which version of the doSomething method can be called on the variable kid?
Parent kid = new Child();
(Multiple Choice)
4.7/5
(43)
Consider the classes shown below: public class Parent
{
Public void doSomething(){/* Implementation not shown */}
}
Public class Child extends Parent
{
Public void doAnotherThing(){/* Implementation not shown */}
}
Which lines in the following code will compile without error?
Child kid = new Child();
Kid)doSomething(); // line 1
Kid)doAnotherThing(); // line 2
(Multiple Choice)
4.9/5
(31)
Consider the following code snippet: public class Vehicle
{
) . .
Public void setVehicleClass(double numberAxles)
{
) . .
}
}
Public class Motorcycle extends Vehicle
{
) . .
Public void setVehicleClass(double numberAxles)
{
) . .
}
}
Which of the following statements is correct? (I changed the wording below, because methods override methods. . .classes don't override methods)
(Multiple Choice)
4.8/5
(30)
Showing 21 - 40 of 101
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)