Java Semester 1 Review

¡Supera tus tareas y exámenes ahora con Quizwiz!

A collection that holds key/value pairs is referred to as a(n) ____. a. map c. interface b. simple collection d. array

A

A(n) ____ provides services such as opening and closing files and displaying output. a. operating system c. analytical engine b. compiler d. transistor

A

Breaking a class that performs more than one task apart into two or more classes is called ____. a. generalization c. refactoring b. merging d. setting state

A

Casts come in two types: ____ and ____. a. implicit; explicit c. abstract; concrete b. general; specific d. public; private

A

Collections are defined as interfaces in order to allow the greatest level of ____. a. abstraction c. detail b. specificity d. readability

A

In the partial class definition below, what is the return type of calculateGPA()? a. float c. public b. int d. string

A

Methods that create an instance of a class are called ____. a. constructors c. mutators b. accessors d. instantiators

A

Suppose that Dog is a subclass of Animal, Beagle a subclass of Dog, and Rex a subclass of Beagle. Which of the following statements is true? a. A method that takes a Dog as an argument will also accept an Animal. b. Dog is derived from Beagle. c. Beagle inherits the methods and fields of Rex. d. A method that takes an Animal as an argument will also accept a Rex.

A

Suppose that Plant is a subclass of Organism, Vine is a subclass of Plant, and Grape is a subclass of Vine. If Plant overrides the grow() method of Organism, which of the following statements refers to a different method from the others? Assume that organism is an object of the Organism class, plant an object of the Plant class, etc. a. organism.grow(); c. vine.grow(); b. plant.grow(); d. grape.grow();

A

The static method of JOptionPane that displays a pop-up message box is called ____. a. showMessage() c. drawDialogBox() b. drawMessage() d. showMessageDialog()

A

What keyword is used to skip over the remaining lines in the body of a loop, starting the next iteration immediately? a. continue c. restart b. break d. default

A

What name is given to the programming technique of creating a small, incomplete working product, and then adding features one by one, fixing problems as you find them? a. successive approximation c. encapsulation b. linear regression d. modularity

A

When a method of an applet calls the repaint() method, the applet's ____ method is called. a. paint() c. draw() b. init() d. repaint()

A

When objects do not have to know the details of one another's implementations, it is called ____. a. encapsulation c. extension b. refactoring d. signature

A

Which method must be implemented by a class that implements the ActionListener interface? a. actionPerformed() c. paint() b. mouseClicked() d. mouseEntered()

A

Which of the following Java classes offers a way to obtain user input graphically? a. JOptionPane c. JApplet b. Iterator d. String

A

Which of the following classes would most likely serve as a base class for the others? a. Vehicle c. Motorcycle b. Truck d. Car

A

Which of the following could be a machine-language instruction? a. 011001 10110 00101 01101 11100 111000 b. mov ax, 0002 c. printf("hello"); d. goto 10

A

Which of the following is considered an object-oriented programming language? a. C# c. Basic b. C d. Pascal

A

Which of the following is not an intrinsic type in Java? a. void c. double b. long d. byte

A

Which of the following methods may be implemented by classes extending the JApplet class, to specify actions be taken only once, when the applet is loaded? a. init() c. run() b. start() d. begin()

A

Which of the following variable names is NOT commonly used for counters? a. h c. j b. i d. k

A

A class that is defined inside another class is called a(n) ____. a. subclass c. semi-class b. inner class d. constructor

B

A method that takes a value type as an argument works with a(n) ____ of the value passed in. a. subclass c. implementation b. copy d. simplification

B

An if statement that uses many if-else constructs to test the value of the same integer expression might be better written using a ____ statement. a. for c. while b. switch d. break

B

An interface does not provide a(n) ____ for the methods it defines. a. declaration c. implementation b. return type d. parameter list

B

In an array of a user-defined type, the elements are initialized to ____, a special value indicating that the objects have not yet been created. a. empty c. 0 b. null d. \u0000

B

In designing the ____ , his second attempt at a computing machine, Charles Babbage outlined the basic components of today's computers. a. Difference Engine c. abacus b. Analytical Engine d. ENIAC

B

Software that interacts with the hardware on a very basic level is called ____ software. a. applications c. database b. systems d. administrator

B

Suppose that the class Dog has a member variable age, an integer, and methods scratch() and rollOver(). Suppose also that rollOver() has a local variable numTimes, an integer. Which of the following statements about Dog is NOT true? a. A statement in rollOver() may change the value of age. b. A statement in scratch() may change the value of numTimes. c. A statement in rollOver() may assign the value of age to numTimes. d. A statement in scratch() may store the value returned by rollOver() in a local variable returnVal.

B

The ____ operator is used to determine whether or not an object belongs to a certain class. a. % c. hasType b. instanceOf d. %=

B

The abbreviation API stands for ____. a. applied predefined interface c. abstract public interface b. application program interface d. abstract protected interface

B

The property of an array that tracks the total number of elements it contains is its ____ property. a. size c. numElements b. length d. span

B

What is it called when a listener tells another object to notify it when an event associated with that object fires? a. initializing c. signing up b. registering d. declaring

B

What value is printed when the following code is executed? mc029-1.jpg a. 10 c. 20 b. 24 d. 12

B

When multiple methods with the same name are created within a single class, it is called ____. a. subclassing c. decoupling b. overloading d. multiple inheritance

B

When referring to the parts of a Java program, three of the following terms have the same meaning. Which is NOT a synonym for any of the others? a. fields c. properties b. methods d. instance variable

B

When simulating a one-dimensional cellular automaton, the state of a particular cell can be represented, after examining its neighboring cells, as a(n) ____. a. universal constructor c. two-dimensional array b. bit pattern d. interface

B

Which HTML tag is used to specify the name of a Java applet's .class file? a. <HEAD> c. <TITLE> b. <APPLET> d. <BODY>

B

Which keyword must be used when declaring fields and methods that are accessible only from the class in which they reside or its derived classes. a. private c. public b. protected d. static

B

Which keyword, when used in a method, refers to the object to which that method belongs? a. static c. me b. this d. current

B

Which of the following is not a value type? a. int c. double b. String d. long

B

Which of the following is the best name for a constant storing the number of seconds in an hour? a. sph c. S_P_H b. SECONDS_PER_HOUR d. secondsPerHour

B

Which of the following is the name given to the method that represents the starting point of a Java program? a. start() c. run() b. main() d. init()

B

Which of the following terms describes the ++ operator in the expression (y ++)? a. prefix increment c. prefix decrement b. postfix increment d. postfix decrement

B

Which problem domain might contain the objects (orders, specials, supplier contacts)? a. building a home c. packing a suitcase b. managing a restaurant d. writing a paper

B

A cast can be written between which pair of symbols? a. { } c. ( ) b. [ ] d. < >

C

A collection in which objects are removed in the order in which they were added is called a ____. a. stack c. queue b. list d. heap

C

A variable that exists only to store a temporary value during part of a calculation is called a(n) ____ variable. a. overloaded c. interim b. uninitialized d. global

C

If the Beagle class extends the Dog class, then the Dog class is the ____ and the Beagle class the ____. a. root class; base class c. base class; derived class b. more specific class; less specific class d. abstract class; concrete class

C

In Java a(n) ____ is a definition of a type and a(n) ____ is an instance of a type. a. implementation; class c. class; object b. variable; field d. field; method

C

In Java, simple branching is implemented using which keyword? a. while c. if b. for d. switch

C

In good encapsulation, (1) the internal state of a class is hidden from its clients and (2) a class looks to other classes to fulfill tasks outside its area of responsibility. These practices are referred to as ____ and ____. a. delegation; implementation c. data hiding; delegation b. implementation; data hiding d. data hiding; declaration

C

In the Java coordinate system, the point (0, 0) is at the ____ corner of the drawing area. a. lower left c. upper left b. lower right d. upper right

C

In the code, public class HelloWorld extends JApplet which of the following is used as an identifier? a. class c. HelloWorld b. extends d. public

C

In the context of the Java language, which of the following are NOT synonyms? a. base class; superclass c. specialization; generalization b. derived class; subclass d. inheritance; specialization

C

Iteration over a two-dimensional array is best accomplished using ____. a. a while loop c. a nested for loop b. an if/else statement d. a switch statement

C

Java is considered a(n) ____ programming language. a. relatively old c. object-oriented b. functional d. low-level

C

Making a class responsible for its own behavior ____ that class from its clients. a. overloads c. decouples b. invokes d. extends

C

Suppose class A calls a method belonging to class B. Which of the following statements is definitely true? a. B is a public interface of A c. A is a client of B b. A is a private implementation of B d. B is a subclass of A

C

Suppose you are writing a class that already has the method mc023-1.jpg Which of the following methods may NOT override myMethod()? a. void myMethod(int x, int y, int width, int height); b. int myMethod(double x, double y); c. void myMethod(int width, int height); d. int myMethod(int x, int y, double radius);

C

The ____ class provides a better alternative to an "empty" for loop when generating a pause. a. Listener c. Timer b. Pause d. Graphics

C

The main() function takes as its argument an array of ____. a. doubles c. strings b. StringBuffers d. ints

C

Three of the following statements are equivalent. Which is NOT equivalent to any of the others? a. x = x + 1; c. x + x = 1; b. x += 1; d. x ++;

C

To describe a set of methods that multiple classes may implement and which encompass a specific behavior, a(n) ____ should be used. a. abstract class c. interface b. derived class d. extended class

C

What does the output shown below depict? mc023-1.jpg a. a graphic user interface c. a histogram b. an inheritance hierarchy d. an interface

C

What value is output by the following code? mc028-1.jpg a. 1 c. 3 b. 2 d. 4

C

When a method is implemented with a snippet of code that shows what it is intended to do, but does not actually make it work (often to allow the class to which the method belongs to implement an interface), it is called ____ the method. a. glossing over c. framing b. deferring d. stubbing out

C

When an object is retrieved from a collection, it must be ____ before methods specific to that object are invoked. a. declared c. cast b. initialized d. extended

C

When the keyword extends is used in an interface declaration, it must be followed by the name(s) of one or more ____. a. classes c. interfaces b. methods d. abstract classes

C

Which name should be given to a file that defines the class EmployeeRecord? a. employeeRecord.java c. EmployeeRecord.java b. employee_record.java d. EMPLOYEE_RECORD.java

C

Which of the following best summarizes the process of developing a successful piece of software? a. testing; analysis; implementation; design; deployment and maintenance b. testing; design; analysis; implementation; deployment and maintenance c. analysis; design; implementation; testing; deployment and maintenance d. design; implementation; testing; deployment and maintenance; analysis

C

Which of the following determines how many bytes of memory an object takes up? a. the scope in which it is declared b. the address in memory at which it is stored c. its type d. whether or not it is declared as public

C

Which of the following is NOT considered a high-level programming language? a. C c. assembly b. Basic d. Java

C

Which of the following is not a relational operator? a. > c. -= b. == d. <=

C

Which of the following methods need NOT be implemented by a class that implements MouseListener? a. mouseEntered() c. mouseScrolled() b. mousePressed() d. mouseClicked()

C

Which of the following names would be most appropriate, in terms of meaning and convention, for an interface implemented by classes that can "draw themselves" to the screen? a. canDraw c. Drawable b. Picture d. draws

C

Which of the following statements changes the value stored in x if it initially contains the value 4? a. x != 4; c. x %= 3; b. x == 2; d. x % 4;

C

Which special character code inserts a tab when used in a string passed to the println() method? a. \n c. \t b. <tab> d. %t

C

Which term is used to describe the conversion of a variable of one type to a different type? a. initializing c. casting b. declaring d. concatenation

C

In Java, when one or more classes are derived from another class, taking on that class's attributes, it is referred to as ____. a. encapsulation c. expansion b. reimplementation d. inheritance

D

In event-driven programming, a(n) ____ raises or fires an event, while a(n) ____ responds to an event. a. listener; object c. operator; operand b. class; user interface d. event source; event handler

D

In the context of computer science, a model could be defined as ____. a. a solution to a problem c. an element of a program's user interface b. an operating system d. a simplification of a complex system

D

Some languages allow definition of classes which derive from more than one other class. This idea is known as ____. a. free derivation c. encapsulation b. multiple inheritance d. interfacing

D

The part of memory in which instances of classes are created is called ____. a. the stack c. the default constructor b. the data segment d. the heap

D

The set of utility classes and interfaces for working with collections of objects is called the ____. a. collector c. garbage collector b. collection hierarchy d. collection framework

D

Using private member variables promotes the concept of ____. a. declaration c. instantiation b. problem domains d. data hiding

D

What is the name given to the program structure in which a block of statements are repeated multiple times? a. simple sequence c. evaluation b. branching d. iteration

D

What is the shortest delay possible between the events generated by a Timer object? a. 1 microsecond c. 1 second b. 100 microseconds d. 1 millisecond

D

What value is printed for x when the code below is executed? mc029-1.jpg a. 1 c. 2 b. 5 d. 0

D

When a method of the Graphics class is called to draw an object that is entirely offscreen, what is the result? a. An error is generated. b. The object is placed at the center of the applet or application window. c. The object is drawn in its entirety at the edge of the screen and as close as possible to the specified offscreen location. d. The object is not drawn.

D

When common behavior is removed from two subclasses of the same class and placed in the class from which they are derived, it is called ____. a. breaking down c. inheritance b. specializing d. factoring up

D

Which name is given to an error identified by the Java compiler? a. logical error c. runtime error b. bug d. syntax error

D

Which of the following expressions could be used as the condition in an if statement? a. x %= y c. x = y b. x ++ d. x != y

D

Which of the following identifiers correctly employs camel case notation? a. MyVar c. myVAR b. My_Var d. myVar

D

Which of the following is not a self-assignment operator? a. += c. *= b. %= d. !=

D

Which of the following is not considered a type in Java? a. int c. double b. boolean d. private

D

Which of the following statements appropriately declares and instantiates an array of 20 integers? a. array = int[20]; c. int[] array = int[20]; b. int array = new int[19]; d. int[] array = new int[20];

D

Which of the following statements correctly declares and allocates a two-dimensional array of doubles? a. double[4][3] array; b. double[][] array[4][3]; c. double array = new double[4][5]; d. double[][] array = new double[4][5];

D

Which tag is used in a switch statement to specify an action that will be taken if none of the other cases are matched? a. case c. break b. other d. default

D

A class that implements an interface need not implement all of its methods.

False

A constructor may be declared with or without a return type.

False

A local variable declared in someMethod() with the public identifier can be accessed by someOtherMethod() if both methods belong to the same class.

False

Attempting to add an object to an ArrayList that is already full will generate a runtime error.

False

In Java, each file may have several public class definitions.

False

In Java, objects store data but offer no means of manipulating it.

False

In an array of Boolean values, each element is initialized to true.

False

Increasing the value of FREQ in the following statement will cause the Timer object instantiated to fire events more often. timer = new Timer(FREQ, this);

False

Inherited methods and fields must be declared in the subclass before they are used.

False

Integrated circuits produce more heat than transistors.

False

One interface may NOT be derived from another.

False

Subclasses of a class that implements an interface must explicitly implement that interface using the implements keyword for the compiler to recognize that they define the necessary methods.

False

The Java compiler will interpret the variable names currentSpeed and CurrentSpeed as referring to the same thing.

False

The elements of an array are always reference types.

False

The expression (x = x) evaluates to true given that x has been declared as an int.

False

The fillOval() method of the Graphics class draws an oval of the specified width and height centered at the x and y coordinates provided.

False

The parameters to a method may be passed in any order.

False

The set() method, initially declared as

False

The value of a constant may be changed only by a method of the class in which it is declared.

False

The width and height fields of a Dimension object are private.

False

Typically the value in a key/value pair consists of a smaller amount of data than the key.

False

When a variable of type int is supplied as an argument to a method, the method may change the value stored in that variable.

False

A class defined within another class has access to the private member variables of the class in which it is defined.

True

A class that extends another class may also implement an interface.

True

A constructor of a class may be marked private, so long as the class has at least one public constructor.

True

A programmer may create new types in Java.

True

A static method may be called without creating an instance of the class in which it resides.

True

A variable may be defined of type A, where A is an interface.

True

All keywords in Java are lowercase.

True

All user-defined types are reference types.

True

An ArrayList may be resized dynamically while the program runs.

True

An interface may define a constant.q

True

Any program must be converted to machine code before it is executed, regardless of the language it is written in.

True

Each assembly-language instruction corresponds to a single machine-language instruction.

True

Erasing in Java can be accomplished by simply drawing an object in the background color over the object being erased.

True

Every time a String object is "changed" a new String object is actually created.

True

Given that Rose is a subclass of Flower, the following statement is legal in Java.

True

Heterogeneous collections are often considered poor programming style.

True

If all of a class's subtypes contain the same behavior or characteristic, then the shared behavior or characteristic should be moved "up the hierarchy"; that is, it should be placed in the more general class from which the subtypes were derived.

True

If there are no other references to an object stored in a collection, and that object is removed from the collection, it will be deleted by the garbage collector.

True

Java programs are processor-independent.

True

The constructor of a class may be overloaded.

True

The expression (('c' - 'a') + 'b' == 'd') evaluates to true.

True

The expressions between the parentheses in a for statement are optional, and may be left out so long as the necessary semicolons are still present as spacers.

True

The following code will generate a compile error.

True

The following code will generate an error.

True

The key difference between a while loop and a do...while loop is that the while loop tests its condition before the body of the loop is executed, and the do...while loop tests its condition after the body of the loop is executed.

True

The methods of a class may access any of its member variables.

True

The part of the Java Virtual Machine that is responsible for destroying objects to which there are no active references is called the "garbage collector."

True

The type int is an intrinsic (or built-in) type.

True

Two classes may implement the same interface with methods that do completely different things.

True

Two methods may have the same name and the same parameter names, so long as the types of the parameters are not identical.

True

When a class is declared without an access designation (public or private), it will be visible to other classes in the same file only.

True

When an object is added in the middle of an ArrayList using the add() method, all objects at or after the insertion point are shifted toward higher indexes to make room.

True


Conjuntos de estudio relacionados

CHAPTER 6 THE THREE ENERGY SYSTEMS WORKING TOGETHER TO PRODUCE ATP

View Set

chapter 16 - disability income insurance

View Set

CH_11_Skull and Cranial Bones (SELF-TEST)

View Set

pearson elemental geosystems ch 10

View Set

Microeconomics Exam chapters 6-8

View Set