Exam 9: Inheritance

arrow
  • Select Tags
search iconSearch Question
flashcardsStudy Flashcards
  • Select Tags

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 methods inherited from Car should SportsCar override?

(Essay)
4.9/5
(31)

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)

Abstract methods are used when defining

(Multiple Choice)
4.9/5
(31)

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. 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. -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
close modal

Filters

  • Essay(0)
  • Multiple Choice(0)
  • Short Answer(0)
  • True False(0)
  • Matching(0)