Core Java Flashcards
If a variable is declared as private, where may thevariable be accessed?
A private variable may only be accessed within the class in which it is declared.
What is an object’s lock and which object’s havelocks?
An object’s lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object’s lock. All objects and classes have locks. A class’s lock is acquired on the class’s Class object.
What is the Dictionary Class?
The Dictionary class provides the capability to store key-value pairs.
How are the elements of a BorderLayout organized?
NEWS Centre
What is the % operator?
Modulous division
When can an object reference be cast to an interfacereference?
When the object implements the instance to be referenced
What is the difference between a Window and aFrame?
The Frame class extends Window to define a main application window that can have a menu bar.
Which class is extended by all other classes?
The Object class is extended by all other classes.
Can an object be garbage collected while it is stillreachable?
No only while unreachable
Is the ternary operator written x : y ? z or x ? y : z ?
X?y:z
What is the difference between the Font andFontMetrics classes?
The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object.
How is rounding performed under integer division?
The fractional part of the result is truncated.
What happens when a thread cannot acquire a lockon an object?
enters waiting state
What is the difference between the Reader/Writerclass hierarchy and the InputStream/OutputStream classhierarchy?
The Reader/Writer class hierarchy is character-oriented, and the InputStream/ OutputStream class hierarchy is byte-oriented.
What classes of exceptions may be caught by a catchclause?
A catch clause can catch any exception that may be assigned to the Throwable type.
If a class is declared without any access modifiers,where may the class be accessed?
A class that is declared without any access modifiers is said to have package access. This means that the class can only be accessed by other classes and interfaces that are defined within the same package.
Q117. What is the SimpleTimeZone class?
The SimpleTimeZone class provides support for a Gregorian calendar.
What is the Map interface?
The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values.
Does a class inherit the constructors of itssuperclass?
nope
For which statements does it make sense to use alabel?
statements that can enclose a break or continue statement.
What is the purpose of the System class?
access to system resources
Which TextComponent method is used to set aTextComponent to the read-only state?
setEditable()
How are the elements of a CardLayout organized?
The elements of a CardLayout are stacked, one on top of the other, like a deck of cards.
Is &&= a valid Java operator?
nope
Name the eight primitive Java types?
you know this
Which class should you use to obtain designinformation about an object?
The Class class
What is the relationship between clipping andrepainting?
When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.
Is “abc” a primitive value?
nope. String obj.
What is the relationship between an event-listenerinterface and an event-adapter class?
An event-listener interface defines the methods that must be implemented by an event handler for a particular kind of event. An event adapter provides a default implementation of an event-listener interface.
What restrictions are placed on the values of eachcase of a switch statement?
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.
What modifiers may be used with an interfacedeclaration?
public or abstract
Is a class a subclass of itself?
yep
What is the highest-level event class of the eventdelegationmodel?
java.util.EventObject
What event results from the clicking of a button?
Action Event
How can a GUI component handle its own events?
A component can handle its own events by implementing the required event-listener interface and adding itself as its own event listener.
What is the difference between a while statementand a do statement?
A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.
How are the elements of a GridBagLayout organized?
The elements of a GridBagLayout are organized according to a grid. However, the elements are of different sizes may occupy more than one row or column of the grid. In addition, the rows and columns may have different sizes.