Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

. 1.Given the following Java code that paints this image, select the third vertex of the border that is painted. int[] x = {16, 22,

. 1.Given the following Java code that paints this image, select the third vertex of the border that is painted.

int[] x = {16, 22, 28, 30, 24, 10};

int[] y = {22, 20, 26, 18, 12, 12};

g.setColor(new Color(17, 242, 44));

g.fillPoly(x, y, 6);

g.setColor(Color.BLACK);

g.drawPoly(x, y, 6)

; A. (24,12) B. (30,18) C. (10,12) D. (28,26)

2. What must be imported to get most graphics components?

A. java.Graphics B. java.awt.* C. java.util.* D. java.*

3. To set the background colour of a JApplet or a JFrame, the following Java statement could be used: getContentPane().setBackground(new Color(0xff00ff)); .

An alternative Java statement that achieves exactly the same effect is:

getContentPane().setBackground(new Color(--,--,--))

A. 250,00,250 B. 255,0,255 C. 255,00,255 D. 250,0,250

4. Which of the painting statements would produce the oval shown in this image?

You can assume that the drawing colour has already been set to red

A. g.fillOval(20, 30, 35, 60); B. g.fillOval(20, 30, 60, 35); C. g.fillOval(35, 60, 20, 30); D. g.fillOval(20, 30, 35, 60);

5. The following statements correctly describe benefits of the technique called abstraction except?

A. Focus only on high-level details B. Focus on low-level details at the appropriate time C. Focus on low-level details first D. Gives a good overview because low-level information is missing .

6. A JTextField object can generate an ActionEvent

A. true B. false C. true but with a button D. false because JTextField is not a component

7. Consider the following Java statement; private static double num = 65.4;

What does the reserved word static mean?

A. The variable num belongs to the object rather than the class. ...3/8 B. The variable num cannot be changed. C. The variable num is fixed in size. D. There is one copy of num per object

8. In the diagram, select all of the methods in ClassA that can be called from a method in ClassB

A. All methods B. setP1(s:String), getP1(): String, getP2(): int C. checkP1() : boolean, checkP2() : boolean D. p1 : String, p2 : int

9. Given the method declaration below, public void m1(int num1, int num2){} which method declaration overload method m1?

A. public void m2(int num1, int num2){} B. public void m1(int num1, double num2){} C. public string m1(int num1, int num2, int num3){} D. public int m1(int num1, int num2){}

10. A class Car and its subclass Yugo both have a method show() which was written by the programmer as part of the class definition. If junker refers to an object of type Yugo, what will the following code do? junker.show();

A. The show() method defined in Yugo will be called. B. The show() method defined in Car will be called. C. The compiler will complain that show() has been defined twice. D. Overloading will be used to pick which show() is called.

11. What restriction is there on using the super reference in a constructor?

A. It can only be used in the parent's constructor. B. Only one child class can use it. C. It must be used in the last statement of the constructor. D. It must be used in the first statement of the constructor.

12. Can an object be a subclass of another object?

A. Yesas long as single inheritance is followed. B. Noinheritance is only between classes. C. Only when one has been defined in terms of the other. D. Yeswhen one object is used in the constructor of another.

13. What is an abstract class?

A. An abstract class is one without any child classes. B. An abstract class is any parent class with more than one child class. C. An abstract class is class which cannot be instantiated. D. abstract class is another name for "base class."

14. Can an abstract class define both abstract methods and non-abstract methods?

A. Noit must have all one or the other. B. Noit must have all abstract methods. C. Yesbut the child classes do not inherit the abstract methods. D. Yesthe child classes inherit both.

15. Can an abstract method be defined in a non-abstract class?

A. Noif a class defines an abstract method the class itself must be abstract. B. Noonly classes are abstract, not methods. C. Yesa method can be declared abstract in any parent as long as the child classes also declare it abstract. D. Yesthere is no restriction on where abstract methods can be defined.

16. What is polymorphism in Java?

A. It is when a single variable is used with several different types of related objects at different places in a program.

B. It is when a program uses several different types of objects, each with its own variable.

C. It is when a single parent class has many child classes.

D. It is when a class has several methods with the same name but different parameter types.

17. Given the method declaration below, public void m1(int num1, int num2){} ...5/8 which method declaration override method m1 when written in a subclass?

A. public void m2(int num1, int num2){} B. public void m1(int num1, double num2){} C. public string m1(int num1, int num2, int num3){} D. public int m1(int num1, int num2){}

18. When a class implements an interface, what must it do?

A. It must redefine each constant from the interface. B. It must declare and provide a method body for each method in the interface. C. It must declare a variable for each constant in the interface. D. It must include a private method for each method in the interface.

19. What is the base class of nearly all Swing classes? A. Object B. Component C. Swing D. JComponent

20. What is the name for a method that responds to events?

A. A container method. B. A snoop method. C. A listener method. D. An application method.

21. Fill in the blanks so that this program displays a JFrame: import java.awt.*; public class microGUI { public static void main ( String[] args ) { JFrame frm = new ___________(); frm.___________( 150, 100 ); frm.___________( true ); } } A. Form, setVisible, setOn B. JFrame, setSize, setVisible C. Frame, setVisible, setSize D. Window, setSize, paint ...6/8

22. Which of the following sets the frame to 300 pixels wide by 200 high?

A. frm.setSize( 300, 200 ); B. frm.setSize( 200, 300 ); C. frm.paint( 300, 200 ); D. frm.setVisible( 300, 200 );

23. What three types of software are needed in a complete GUI program A. GUI Components, Event Listeners, Application Code B. Action Events, Window Objects, Containers C. Frames, Windows, Containers D. Libraries, Toolkits, Interfaces

24. What reserved word is used to distinguish the instance variables of an object from identically named parameters of a constructor?

A. this B. that C. mine D. main

25. What is the class that applets are based on? A. applet B. JApplet C. Apple D. AWT

26. Can the source code for your applet be compiled by the usual javac compiler? A. No---because applets have no main() B. No---the web browser compiles the code. C. Yes---an applet is just another class as far as the compiler is concerned. D. Yes---if you are going to run it from the DOS prompt.

27. If you are using the Graphics object gr and wish to change the pen color to red, what should you do? A. gr.setColor( Color.red ) B. gr.setPen( Color.red ) C. setBackground( Color.red ) D. gr.setRed( )

28. What class is the mother of all classes in Java.

A. Object Class B. Super Class C. Main Class D. None of the above.

29. What type of inheritance is supported in C++

A. Single Inheritance B. Multiple Inheritance C. Super Inheritance D. Sub-class Inheritance.

30. How many methods are in Action Listerner Interface.

A. 1 B. 2 C. 3 D. 4

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Mary Z. Last

8th edition

1285427106, 978-1285427102

More Books

Students also viewed these Databases questions

Question

How many Tables Will Base HCMSs typically have? Why?

Answered: 1 week ago

Question

What is the process of normalization?

Answered: 1 week ago