-
To what value is a variable of the boolean type automatically initialized
The default value of the boolean type is false.
-
Can try statements be nested
Try statements may be tested.
-
What is the purpose of a statement block
A statement block is used to organize a sequence of statements as a single statementgroup.
-
What modifiers may be used with a top-level class
A top-level class may be public, abstract, or final.
-
When is an object subject to garbage collection
An object is subject to garbage collection when it becomes unreachable to the program inwhich it is used.
-
What method must be implemented by all threads
All tasks must implement the run() method, whether they are a subclass of Thread orimplement theRunnable interface.
-
What methods are used to get and set the text label displayed by a Buttonobject
getLabel() and setLabel()
-
-
What is the List interface
The List interface provides support for ordered collections of objects.
-
Is the ternary operator written x : y ? z or x ? y : z ?
It is written x ? y : z.
-
Q: What is it object serialization ?
Serialization is a way to convert objects (including complex data structures such as lists and trees) into a stream of bytes.
-
Q: What is it reflection (introspection) ? Why is reflection possible in the Java language?
Reflection (introspection) is querying a class about its properties, and operating on methods and fields by the name for a given object instance. Reflection is possible in the Java language because of late binding.
-
Q: Why are Java ARchive (JAR) files important?
JAR files bundle .class files and optimize applet downloads.
-
What are abstract classes, abstract methods?
Simply speaking a class or a method qualified with "abstract" keyword is an abstract class or abstract method. You create an abstract class when you want to manipulate a set of classes through a common interface. All derived-class methods that match the signature of the base-class declaration will be called using the dynamic binding mechanism. An abstract method is an incomplete method. It has only...
-
What are native methods? How do you use them?
Native methods are methods that are defined as public static methods within a java class, but whose implementation is provided in another programming language such as C.
-
Are constructors inherited? Can a subclass call the parent's class constructor? When?
You cannot inherit a constructor. That is, you cannot create a instance of a subclass using a constructor of one of it's superclasses. One of the main reasons is because you probably don't want to overide the superclasses constructor, which would be possible if they were inherited. By giving the developer the ability to override a superclasses constructor you would erode the encapsulation abilities...
-
Does Java have destructors?
No garbage collector does the job working in the background
-
Name four methods every Java class will have.
public String toString();public Object clone();public boolean equals();public int hashCode();
-
Are there any other 'marker' interfaces?
java.rmi.Remotejava.util.EventListener
-
What do you mean by static methods?
By using the static method there is no need creating an object of that class to use that method. We can directly call that method on that class. For example, say class A has static function f(), then we can call f() function as A.f(). There is no need of creating an object of class A.
Java Interview Questions
Ans