Java Basics Questions and Answers
1. What is classloader?
|The classloader is a subsystem of JVM that is used to load classes and interfaces.There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.|
2. What is the default value of the local variables?
|The local variables are not initialized to any default value, neither primitives nor object references.|
3. What are the supported platforms by Java Programming Language?
|Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc.|
4. What is constructor?
|Constructor is a special type of method that is used to initialize the object. Constructor is invoked at the time of object creation. It constructs the values i.e. provides data for the object that is why it is known as constructor.|
5. What is final class?
|A final class can't be extended ie., final class may not be subclassed. A final method can't be overridden when its class is inherited. You can't change value of a final variable (is a constant).|
6. When throws keyword is used?
|If a method does not handle a checked exception, the method must declare it using the throwskeyword. The throws keyword appears at the end of a method's signature.|
7. What is the difference between an Interface and an Abstract class?
|An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation. An abstract class is a class which may have the usual flavors of class members (private, protected, etc.), but has some abstract methods.|
8. Why Java is considered dynamic?
|It is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.|
9. Is main a keyword in Java?
|No. next is not a keyword.|
10. Is Empty .java file a valid source file?
|Yes. An empty .java file is a perfectly valid source file.|