Exam 11: Advanced Inheritance Concepts
Exam 1: Creating Java Programs68 Questions
Exam 2: Using Data74 Questions
Exam 3: Using Methods, Classes, and Objects68 Questions
Exam 4: More Object Concepts67 Questions
Exam 5: Making Decisions70 Questions
Exam 6: Looping72 Questions
Exam 7: Characters, Strings, and the Stringbuilder73 Questions
Exam 8: Arrays74 Questions
Exam 9: Advanced Array Concepts74 Questions
Exam 10: Introduction to Inheritance70 Questions
Exam 11: Advanced Inheritance Concepts70 Questions
Exam 12: Exception Handling65 Questions
Exam 13: File Input and Output74 Questions
Exam 14: Introduction to Swing Components74 Questions
Exam 15: Advanced Gui Topics69 Questions
Exam 16: Graphics74 Questions
Exam 17: Applets, Images, and Sound72 Questions
Select questions type
It is common to create an interface when you want a class to implement behavior from more than one parent.
(True/False)
4.9/5
(33)
Why do many programmers consider multiple inheritance to be a difficult concept?
(Essay)
4.8/5
(34)
When you assign a variable or constant of one type to a variable of another type, the behavior is called ____.
(Multiple Choice)
4.7/5
(34)
While a class can inherit from any abstract superclass, it can only implement one interface.
(True/False)
4.8/5
(46)
public abstract class Car
{
private String model;
public abstract void color();
public String getModel()
{
return model;
}
public void setModel(String modelName)
{
model = modelName;
}
}
The above code creates a generic abstract class named Car with an abstract color() method. Using the code below, fill in the shaded statements in order to create a Honda class that extends Car.
public class ____ extends ____
{
public void ____
{
System.out.println("I like your red car!");
}
}
(Essay)
4.8/5
(41)
public abstract class Car
{
private String model;
public abstract void color();
public String getModel()
{
return model;
}
public void setModel(String modelName)
{
model = modelName;
}
}
public class Honda extends Car
{
public void color()
{
System.out.println("red");
}
}
public class Ford extends Car
{
public void color()
{
System.out.println("blue");
}
}
public class MyCars
{
public static void main(String[] args)
{
Honda myHonda = new Honda();
Ford myFord = new Ford();
myHonda.setModel("My Honda is ");
myFord.setModel("My Ford is ");
System.out.print(myHonda.getModel());
myHonda.color();
System.out.print(myFord.getModel());
myFord.color();
}
}
In the above code, the myHonda.getModel() and myHonda.color() method calls produce different output from when the same methods are used with myFord. Explain why this is the case.
(Essay)
4.9/5
(32)
____ compress the data they store, which reduces the size of archived class files.
(Multiple Choice)
4.9/5
(45)
The Object class ____ method converts an Object into a String that contains information about the Object.
(Multiple Choice)
4.9/5
(47)
In other programming languages, such as C++, abstract classes are known as ____________________ classes.
(Short Answer)
4.8/5
(38)
public abstract class Car
{
private String model;
public abstract void color();
public String getName()
{
return model;
}
public void setName(String carModel)
{
model = carModel;
}
}
Using the code above, would it be possible to create a class in which you declare a Car object with the statement Car myCar = new Car("Honda");?
Explain why or why not.
(Essay)
4.8/5
(42)
Showing 61 - 70 of 70
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)