Filters
Question type

Study Flashcards

If you write a toString method to display the contents of an object, object1, for a class, Class1, then the following two statements are equivalent: System.out.println(object1); System.out.println(object1.toString());

A) True
B) False

Correct Answer

verifed

verified

enum constants have a toString method.

A) True
B) False

Correct Answer

verifed

verified

Enumerated types have the __________ method which returns the position of an enum constant in the declaration list.


A) position
B) location
C) ordinal
D) index

E) A) and D)
F) None of the above

Correct Answer

verifed

verified

The "has a" relationship is sometimes called a(n) __________ because one object is part of a greater whole.


A) enterprise
B) possession
C) mutual relationship
D) whole-part relationship

E) A) and D)
F) A) and C)

Correct Answer

verifed

verified

When an object reference is passed to a method, the method may change the values in the object.

A) True
B) False

Correct Answer

verifed

verified

Which of the following is not true about static methods?


A) They are created by placing the key word static after the access specifier in the method header.
B) It is necessary for an instance of the class to be created to execute the method.
C) They are called directly from the class.
D) They are often used to create utility classes that perform operations on data but have no need to store and collect data.

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

A static field is created by placing the key word static __________.


A) after the access specifier and the field's data type
B) after the access specifier and before the field's data type
C) after the field name
D) in brackets, before the field's data type

E) A) and C)
F) A) and B)

Correct Answer

verifed

verified

Given the following method header, what will be returned from the method? public Rectangle getRectangle()


A) the address of an object of the Rectangle class
B) the values stored in the data members of the Rectangle object
C) a graph of a rectangle
D) an object of the class Rectangle

E) C) and D)
F) B) and D)

Correct Answer

verifed

verified

You cannot use the fully-qualified name of an enum constant for ___________.


A) a case expression
B) an argument to a method
C) a boolean expression
D) Any of these

E) All of the above
F) A) and B)

Correct Answer

verifed

verified

A class that is defined inside another class is called a(n) __________.


A) nested class
B) enumerated class
C) inner class
D) helper class

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

When the this variable is used to call a constructor__________.


A) it must be the first statement in the constructor making the call
B) it can be anywhere in the constructor making the call
C) it must be the last statement in the constructor making the call
D) None of these. You cannot use the this variable in a constructor call.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

Java automatically stores a __________ value in all uninitialized static member variables.


A) 0
B) -1
C) null
D) false

E) A) and B)
F) B) and C)

Correct Answer

verifed

verified

An enumerated data type is actually a special type of class.

A) True
B) False

Correct Answer

verifed

verified

If the following is from the method section of a UML diagram, which of the statements below is true? + add(object2:Stock) : Stock


A) This is a private method named add that accepts and returns objects of the Stock class.
B) This is a private method named Stock that adds two objects.
C) This is a public method named add that accepts and returns references to objects in the Stock class.
D) This is a public method named Stock that adds two objects.

E) A) and B)
F) A) and C)

Correct Answer

verifed

verified

A declaration for an enumerated type begins with the __________ key word.


A) enumerated
B) enum type
C) ENUM
D) enum

E) A) and C)
F) C) and D)

Correct Answer

verifed

verified

If a class has a method named finalize, it is called automatically just before an instance of the class is destroyed by the garbage collector.

A) True
B) False

Correct Answer

verifed

verified

When a method's return type is a class, what is actually returned to the calling program?


A) an object of that class
B) a reference to an object of that class
C) the values in the object that the method accessed
D) nothing - the return type is simply for documentation in this situation

E) A) and C)
F) None of the above

Correct Answer

verifed

verified

Given the following declaration: enum Tree ( OAK, MAPLE, PINE ) What is the ordinal value of the MAPLE enum constant?


A) 0
B) 1
C) 2
D) 3

E) A) and B)
F) None of the above

Correct Answer

verifed

verified

If you attempt to perform an operation with a null reference variable __________.


A) the resulting operation will always be zero
B) the results will be unpredictable
C) the program will terminate
D) Java will create an object to reference the variable

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

You cannot use the == operator to compare the contents of __________.


A) objects
B) strings
C) integers
D) Boolean values

E) B) and C)
F) A) and B)

Correct Answer

verifed

verified

Showing 21 - 40 of 52

Related Exams

Show Answer