29 Java Interview Questions and Answers

Compiled By Unknown - No Comments
254. Question: What is the Dictionary class?
Answer : The Dictionary class provides the capability to store key-value pairs

255. Question: How are the elements of a BorderLayout organized?
Answer : The elements of a BorderLayout are organized at the borders (North, South, East, and West) and the center of a container

256. Question: What is the % operator?
Answer : It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand

257. Question: When can an object reference be cast to an interface reference?
Answer : An object reference be cast to an interface reference when the object implements the referenced interface

258. Question: What is the difference between a Window and a Frame?
Answer : The Frame class extends Window to define a main application window that can have a menu bar

259. Question: Which class is extended by all other classes?
Answer : The Object class is extended by all other classes

260. Question: Can an object be garbage collected while it is still reachable?
Answer : A reachable object cannot be garbage collected. Only unreachable objects may be garbage collected

261. Question: Is the ternary operator written x : y ? z or x ? y : z ?
Answer : It is written x ? y : z

262. Question: What is the difference between the Font and FontMetrics classes?
Answer : The FontMetrics class is used to define implementation-specific properties, such as ascent and descent, of a Font object

263. Question: How is rounding performed under integer division?
Answer : The fractional part of the result is truncated. This is known as rounding toward zero

264. Question: What happens when a thread cannot acquire a lock on an object?
Answer : If a thread attempts to execute a synchronized method or synchronized statement and is unable to acquire an object's lock, it enters the waiting state until the lock becomes available

265. Question: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
Answer : The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented

266. Question: What classes of exceptions may be caught by a catch clause?
Answer : A catch clause can catch any exception that may be assigned to the Throwable type. This includes the Error and Exception types

267. Question: If a class is declared without any access modifiers, where may the class be accessed?
Answer : 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

268. Question: What is the SimpleTimeZone class?
Answer : The SimpleTimeZone class provides support for a Gregorian calendar

269. Question: What is the Map interface?
Answer : The Map interface replaces the JDK 1.1 Dictionary class and is used associate keys with values

270. Question: Does a class inherit the constructors of its superclass?
Answer : A class does not inherit constructors from any of its superclasses

271. Question: For which statements does it make sense to use a label?
Answer : The only statements for which it makes sense to use a label are those statements that can enclose a break or continue statement

272. Question: What is the purpose of the System class?
Answer : The purpose of the System class is to provide access to system resources

273. Question: Which TextComponent method is used to set a TextComponent to the read-only state?
Answer : setEditable()

274. Question: How are the elements of a CardLayout organized?
Answer : The elements of a CardLayout are stacked, one on top of the other, like a deck of cards

275. Question: Is &&= a valid Java operator?
Answer : No, it is not

276. Question: Name the eight primitive Java types.
Answer : The eight primitive types are byte, char, short, int, long, float, double, and boolean

277. Question: Which class should you use to obtain design information about an object?
Answer : The Class class is used to obtain information about an object's design

278. Question: What is the relationship between clipping and repainting?
Answer : When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting

279. Question: Is "abc" a primitive value?
Answer : The String literal "abc" is not a primitive value. It is a String object

280. Question: What is the relationship between an event-listener interface and an event-adapter class?
Answer : 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

281. Question: What restrictions are placed on the values of each case of a switch statement?
Answer : During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value

282. Question: What modifiers may be used with an interface declaration?
Answer : An interface may be declared as public or abstract



Tags:

No Comment to " 29 Java Interview Questions and Answers "