Under what conditions is an object’s finalize() method invoked by the garbage collector

The garbage collector invokes an object’s finalize() method when it detects that the object has become unreachable. In Java, the finalize() method is a method of the Object class, and it is called by the garbage collector before an object is reclaimed (garbage collected). However, there are no guarantees about when the finalize() method will be called … Read more

What is the difference between a field variable and a local variable

A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method. In Core Java, the main difference between a field variable (also known as an instance variable or member variable) and a local variable lies in their scope … Read more

What class allows you to read objects directly from a stream

The ObjectInputStream class supports the reading of objects from input streams. In Core Java, the class that allows you to read objects directly from a stream is ObjectInputStream. This class is part of the Java I/O (Input/Output) API and is used for deserializing objects from a stream. The ObjectInputStream reads data written by an ObjectOutputStream and reconstructs … Read more

What class of exceptions are generated by the Java run-time system?

The Java runtime system generates RuntimeException and Error exceptions. In Java, the exceptions generated by the Java run-time system are primarily categorized into two main types: Checked Exceptions: These are exceptions that the Java compiler forces you to either catch (using a try-catch block) or declare that your method may throw using the throws clause. … Read more

What is the difference between a Choice and a List

A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more … Read more