Java Exam Review

Pataasin ang iyong marka sa homework at exams ngayon gamit ang Quizwiz!

Look at the same code above, what will be the coordinates of the center of the oval?

(125,125)

Again using the same code, what will be the coordinates of the third point of the polygon?

(60,140)

To peek at the contents of a jar file, use the flag

-tf

To update the contents of a jar file, use the flag

-uf

To extract the contents of a jar file, use the flag

-xf

Overloading means multiple methods in the same class.

Have the same name, but different parameter lists

To solve a program recursively, you need to identify at least one case in which the problem can be solved without recursion--this is known as

The base case

What is wrong with the following code? public class ClassB extends ClassA { public ClassB() { int init = 10; super(40); } }

The call to the method super must be the first statement in the constructor

If a superclass does not have a default constructor,

Then a class that inherits from it, must call one of the constructors that the superclass does have

The only limitation that static methods have is

They cannot refer to non-static members of the class

A .jar file is an executable java program

True

An abstract class is not instantiated, but serves as a superclass for other classes.

True

Any problem that can be solved recursively can also be solved iteratively.

True

Every class is either directly or indirectly derived from he Object class.

True

It is not possible for a superclass to call a subclass's method.

True

Recursive algorithms are usually less efficient than iterative algorithms.

True

The delay parameter in the Timer constructor is the amount of time between action events, measured in milliseconds.

True

The key word this is the name of a reference variable that an object can use to refer to itself

True

Looking at the same code above, what is the color of the polygon?

Yellow

Like a loop, a recursive method must have

Some way to control the number of times it repeats itself

Given the following code which of the following is true? public class ClassB implements ClassA

ClassB must override each method in ClassA

Whenever you need a component to be painted, call the paint method.

False

What does the following statement do? addButton.addActionListener(new AddButtonListener());

Creates an AddButtonListener object and registers the AddButtonListener object with the addButton

In an inheritance relationship, the derived class (subclass) constructor executes before the superclass constructor.

False

Look at the following code. The method in line ____ will override the method in line _____ 1. public class ClassA 2. { 3. public ClassA() {} 4. public int method1 (int a) {} 5. public int method2 (int b) {} 6. } 7. public ClassB extends ClassA 8. { 9. public ClassB() {} 10. public int method1 (int b) {} 11. public int method2 (double c) {} 12. }

10,4

Given the following code, how many times per second will the TimerListener event be generated? Timer timer = new Timer(500, new TimerListener());

2

Look a the following code. public class GraphicsTest extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.WHITE); int[] xCoords = {20, 20, 60, 100, 140, 140, 100, 60}; int[] yCoords = {20, 100, 140, 140, 100, 60, 20, 40}; g.setColor(Color.YELLOW); g.fillPolygon(xCoords, yCoords, xCoords.length); g.setColor(color.BLACK); } } How many vertices does the polygon have?

8

public class GraphicsTest extends JPanel { public void paintComponent(Graphics g) { super.paintComponent(g); g.setColor(Color.YELLOW); g.fillOval(100, 100, 50, 50); g.setColor(Color.BLACK); g.setFont(new Font("SansSerif", Font.BOLD, 35)); g.drawString("SLOW", 110, 110); } } What shape will the oval have?

Circle

A recursive method is a method that

Calls itself

This refers to the combining of data and code into a single object.

Encapsulation

All recursive algorithms have exactly one base case.

False

If a method in a subclass has the same signature as a method in the superclass, the subclass method overloads the superclass method.

False

Event listeners must

Implement an interface

When the this variable is used to call a constructor

It must be the first statement in the constructor making the call

If a subclass constructor does not explicitly call a superclass constructor:

Java will automatically call the superclass's default constructor just before the code in the subclass's constructor executes

A subclass class can directly access

Only public and protected members of the superclass class

In an interface all methods have

Public Access


Kaugnay na mga set ng pag-aaral

EASA Part 66 : Physics Question6

View Set

Math Exam 4 CH. 14 Questions and How to answers

View Set

Chapter 9 Principles of Finance Review

View Set

Policy provisions, riders and options

View Set

The Start of The Civil War (1861-1865), Chapter 18

View Set

A&P Chapter 5 Integumentary System

View Set

Chapter 4 Human Resource Law (HSCI 3200)

View Set

Connecting with Computer Science Chapter 1

View Set