Total Pageviews

Friday, May 25, 2012

EXAM 3 COMPLETED

Your performance was as follows:

You took 4 minutes on this assessment from Fri May 25 2012 12:10:53 GMT+0530 to Fri May 25 2012 12:14:16 GMT+0530.

Total score: 100.00



1.

Consider a Java program that contains two classes, Programmer and Person. The class Programmer is a subclass of the class Person, and both classes define a method sleep. Which of the following statements will be true about the program?



(a) The method sleep of Programmer will override that of Person when the program is executed.
(b) When the method sleep of Programmer is called, the method sleep of Person will be called first.
(c) The method sleep of Person will override that of Programmer when the program is executed.
(d) The program will not compile.

Correct answer is (a)

Your score on this question is: 11.11

Feedback:


See section 3.2, subsection "Overriding Methods," in the course notes.




2.

Consider the following Java program fragment.
import java.applet.Applet;

public class Hello extends Applet {

...

}

The fragment indicates that



(a) Applet is an instance of Hello
(b) Hello is a subclass of Applet
(c) Applet is a subclass of Hello
(d) Hello is an instance of Applet

Correct answer is (b)

Your score on this question is: 11.11

Feedback:


See sections 3.1 and 3.2 in the course notes.




3.

Which of the following kinds of relationships between classes does inheritance describe?



(a) has-a
(b) uses-a
(c) produces-a
(d) is-a-kind-of

Correct answer is (d)

Your score on this question is: 11.11

Feedback:


See section 3.1 "Introduction to Inheritance" in the course notes.




4.

If class A is a subclass of class B, which of the following statements is (are) true?
All public data and methods of class B are available to class A.
All public data and methods of class A are available to class B.



(a) I only
(b) II only
(c) None
(d) I and II

Correct answer is (a)

Your score on this question is: 11.11

Feedback:


See sections 3.1 and 3.2 in the course notes.




5.

Which of the following indicates that class Dog is a subclass of class Animal?



(a) public class Dog extends Animal
(b) public class Animal extends Dog
(c) public class Dog imports Animal
(d) public class Animal imports Dog

Correct answer is (a)

Your score on this question is: 11.11

Feedback:


See sections 3.1 and 3.2 in the course notes.




6.

Which of the following is true concerning the following example class definition?
public class Hello extends Applet { ...
}
Hello is a superclass of Applet
Hello inherits from Applet
Hello is a subclass of Applet



(a) I and II only
(b) II and III only
(c) III only
(d) II only

Correct answer is (b)

Your score on this question is: 11.11

Feedback:
See sections 3.1 and 3.2 in the course notes.



7.

If the following line of code is the beginning of a class definition, then class _____ is being defined, and it is a _____ of class _____.
public class Game extends Applet



(a) Applet, superclass, Game
(b) Game, subclass, Applet
(c) Game, superclass, Applet
(d) Applet, subclass, Game

Correct answer is (b)

Your score on this question is: 11.11

Feedback:
See sections 3.1 and 3.2 in the course notes.



8.

In the following program segment, the call super(len,wid) invokes the constructor for which class?
public class CustomWindow extends MyWindow implements ActionListener

{

public CustomWindow(int len, int wid, Font ft)

{

super(len, wid);

}

}



(a) MyWindow
(b) ActionListener
(c) Font
(d) CustomWindow

Correct answer is (a)

Your score on this question is: 11.11

Feedback:


See section 3.2 "Using Inheritance" in the course notes.




9.

Which of the following Java keywords can be used to invoke a superclass constructor for the class in which it appears?



(a) super
(b) this
(c) protected
(d) extends

Correct answer is (a)

Your score on this question is: 11.11

Feedback:


See Chapter 12, page 504, in the course textbook.




Go to top of assessment.

Total score: 100.00

© Copyright 2011 iCarnegie, Inc. All rights reserved.

No comments:

Post a Comment