Exam 9: Inheritance
Exam 1: Introduction65 Questions
Exam 2: Data and Expressions77 Questions
Exam 3: Using Classes and Objects58 Questions
Exam 4: Writing Classes56 Questions
Exam 5: Conditionals and Loops37 Questions
Exam 6: More Conditionals and Loops36 Questions
Exam 7: Object-Oriented Design76 Questions
Exam 8: Arrays70 Questions
Exam 9: Inheritance71 Questions
Exam 10: Polymorphism70 Questions
Exam 11: Exceptions68 Questions
Exam 12: Recursion68 Questions
Exam 13: Collections68 Questions
Select questions type
For the questions below, assume that Student, Employee and Retired are all extended classes of Person, and all four classes have different implementations of the method getMoney. Consider the following code where ... are the required parameters for the constructors:
Person p = new Person(...);
int m1 = p.getMoney( ); // assignment 1
p = new Student(...);
int m2 = p.getMoney( ); // assignment 2
if (m2 < 100000) p = new Employee(...);
else if (m1 > 50000) p = new Retired(...);
int m3 = p.getMoney( ); // assignment 3
-Consider an applet that implements MouseListener. Assume that the applet has five instance data, int x1, x2, y1, y2, and boolean inside. The four int values represent the two end-points of a box (x1, y1 is the upper left hand point and x2, y2 is the lower right hand point). Which of the following properly defines code that will determine whenever the mouse button is clicked if the mouse is currently inside this box or not. If the mouse is inside the box, inside is set to True, otherwise it is set to false.
(Multiple Choice)
5.0/5
(49)
Explain the difference between implementing an interface and a derived class.
(Essay)
4.9/5
(44)
The protected visibility modifier provides the best possible encapsulation that permits inheritance.
(True/False)
4.8/5
(36)
JApplet is an extension of the Applet class and is found in the ________ library.
(Multiple Choice)
4.9/5
(34)
For the questions below, consider the following class definition:
public class AClass
{
protected int x;
protected int y;
public AClass(int a, int b)
{
x = a;
y = b;
}
public int addEm( )
{
return x + y;
}
public void changeEm( )
{
x++;
y--;
}
public String toString( )
{
return "" + x + " " + y;
}
}
-You want addEm to now add all three values and return the sum and changeEm to change x and y, but leave z alone. Which should you do?
(Multiple Choice)
4.9/5
(35)
Explain the difference between using an imported class and extending a class.
(Essay)
4.9/5
(40)
Consider the following class hierarchy and answer these questions.
-If A, B, Y and Z all contain the same instance data d1, then d1 should be declared in X and inherited into Y, Z, A and B.

(True/False)
4.8/5
(31)
For the questions below, use the following partial class definitions:
public class A1
{
public int x;
private int y;
protected int z;
...
}
public class A2 extends A1
{
protected int a;
private int b;
...
}
public class A3 extends A2
{
private int q;
...
}
-Which of the following lists of instance data are accessible in A3?
(Multiple Choice)
4.9/5
(35)
If you instantiate an Abstract class, the class or object you wind up with
(Multiple Choice)
4.8/5
(33)
For the questions below, consider the following class definition:
public class AClass
{
protected int x;
protected int y;
public AClass(int a, int b)
{
x = a;
y = b;
}
public int addEm( )
{
return x + y;
}
public void changeEm( )
{
x++;
y--;
}
public String toString( )
{
return "" + x + " " + y;
}
}
-A variable declared to be of one class can later reference an extended class of that class. This variable is known as
(Multiple Choice)
4.7/5
(34)
The reserved word, extends, is used to denote a has-a relationship.
(True/False)
4.8/5
(42)
If class AParentClass has a protected instance data x, and AChildClass is a derived class of AParentClass, then AChildClass can access x but can not redefine x to be a different type.
(True/False)
4.8/5
(29)
Consider a class Plane and three subclasses, Glider, PropPlane and Jet. What instance data that should be declared in Plane and what instance data should be declared in one of the three subclasses. Come up with at least 2 instance data unique to each of the four classes given that all instance data of Plane will be inherited into the subclasses.
(Essay)
4.9/5
(27)
All classes in Java are directly or indirectly subclasses of the ________ class.
(Multiple Choice)
4.8/5
(41)
Consider the following class hierarchy and answer these questions.
-A is a derived class of X.

(True/False)
4.9/5
(43)
As described in the Software Failure, the cause of the 2004 LA Air Traffic Control incident was
(Multiple Choice)
4.8/5
(37)
Java does not support multiple inheritance, but some of the abilities of multiple inheritance are available by
(Multiple Choice)
4.9/5
(40)
If a programmer writes a class wanting it to be extended by another programmer, then this programmer must
(Multiple Choice)
4.9/5
(42)
For the questions below, consider the following class definition:
public class AClass
{
protected int x;
protected int y;
public AClass(int a, int b)
{
x = a;
y = b;
}
public int addEm( )
{
return x + y;
}
public void changeEm( )
{
x++;
y--;
}
public String toString( )
{
return "" + x + " " + y;
}
}
-Two children of the same parent class are known as
(Multiple Choice)
4.8/5
(38)
Showing 21 - 40 of 71
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)