CS 162 Quiz 3

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

Which of the following is true?

A child class can extend just one parent and can implement zero or more interfaces.

In Java, what do you call an area on the screen that has nice borders and various buttons along the top border?

A frame

What must a non-abstract child do about an abstract method in its parent class?

A non-abstract child must define a method with the same signature and same return type as the parent's abstract method.

What is an abstract class?

An abstract class is class which cannot be instantiated.

What is an abstract method?

An abstract method does not have a body and is declared with the reserved word abstract.

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

No—if a class defines an abstract method the class itself must be abstract.

What two things must your program do to respond to a particular type of event?

Create an event listener object for the type of event, and register it with the object that generates those events.

Can an abstract parent class have non-abstract children?

No—an abstract parent must have only abstract children.

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

It must declare and provide a method body for each method in the interface.

What letter do many Swing class names start with?

J

Can an interface ever contain method bodies?

No

What must be true if a child of an abstract parent class does not override all of the parent's abstract methods?

The child class itself must be declared to be abstract.

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

Yes - the child classes will inherit both

Is the following a correct way to start out a class definition: public class SomeClass implements MyInterface { //Class fields and methods }

Yes—SomeClass is automatically a child class of Object class.

Can an interface name be used as the type of a variable, like this (assume that SomeInterface is a validly defined java interface): public static void main( String[] args ) { SomeInterface x; //other code... }

Yes—the variable can refer to any object whose class implements the interface.

How is a GUI component (such as a button) placed into a JFrame?

getContentPane().add( Component c )

Here is an abstract method defined in some abstract parent class: public abstract int sumUp ( int[] arr ); Which of the following is required by all of it's non-abstract child classes?

public int sumUp ( int[] arr ) { . . . }

The STATIC type of any variable refers to

the declared compile-time type of the the variable


Ensembles d'études connexes

Digital & Content Marketing Practice Questions Exam 2

View Set

Agents to control blood glucose levels prepu

View Set

Chapter 66: Shock, Sepsis, and Multiple Organ Dysfunction Syndrome

View Set