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, 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;
}
}
-Which of the following is True regarding Java classes?
(Multiple Choice)
4.8/5
(27)
You may use the super reserved word to access a parent class'private members.
(True/False)
4.8/5
(27)
What is the advantage of extending an adapter class rather than implementing a listener interface?
(Essay)
4.7/5
(38)
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 is True with respect to A1, A2 and A3?
(Multiple Choice)
4.9/5
(40)
Clicking the mouse button generates three mouse events, mousePressed, mouseClicked, and mouseReleased.
(True/False)
4.9/5
(43)
Java doesn't support multiple inheritance; but it does support the implementation of multiple Interfaces.
(True/False)
4.7/5
(30)
An Applet implements MouseMotionListener. Write the mouseMoved and paint methods for an applet that will display the location of the mouse as an (x, y) coordinate. The output should be given at the current mouse location.
(Essay)
4.9/5
(41)
Consider the following class hierarchy and answer these questions.
-If classes C1 and C2 both implement an interface Cint, which has a method whichIsIt, and if C1 c = new C1( ); is performed at one point of the program, then a later instruction c.whichIsIt( ); will invoke the whichIsIt method defined in C1.

(True/False)
4.8/5
(36)
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;
}
}
-Consider that you want to extend AClass to BClass. BClass will have a third int instance data, z. Which of the following would best define BClass'constructor?
(Multiple Choice)
4.9/5
(35)
Showing 61 - 71 of 71
Filters
- Essay(0)
- Multiple Choice(0)
- Short Answer(0)
- True False(0)
- Matching(0)