The Knowledge Hub

Wednesday 1 July 2015

INTERVIEW QUESTIONS FOR JAVA

1. List any five features of Java?Ans. Some features of Java includes Object Oriented, Platform Independent, Robust, Interpreted, Multithreaded

2. Why is Java Architectural Neutral?Ans: Java compiler creates an architecture-neutral object file , which makes the compiled
code to be executable on many any Processor, with the help of Java runtime Environment.

3. What are the supported platforms by Java Programming Language?Ans: 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. How Java enabled High Performance?Ans: Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode, which is a program that contains instructions that must be interpreted into instructions that can be sent directly to the processor.

5. List two Java IDE’s?Ans: Eclipse, Netbeans.

6. List some Java keywords?Ans: import, super, finally, etc.

7. What do you mean by Object?Ans: Object is a runtime entity and it’s state is stored in fields and behavior is shown via methods.
Methods operate on an object's internal state and serve as the primary mechanism for object-toobject
communication.

8. What is class?Ans: A class is a blue print from which individual objects are created. A class can contain fields and
methods to describe the behavior of an object.

9. What kind of variables a class can consist of?Ans: Local variable, instance variables and class variables.

10. What is a Local Variable?Ans: Variables defined inside methods, constructors or blocks are called local variables. The variable
will be declared and initialized within the method and it will be destroyed when the method has
completed.

11. What is a Instance Variable?Ans: Instance variables are variables within a class but outside any method. These variables are
instantiated when the class is loaded.

12. What is a Class Variable?Ans: These are variables declared with in a class, outside any method, with the static keyword.

13. What do you mean by Constructor?Ans: Constructor gets invoked when a new object is created. Every class has a constructor. If we do
not explicitly write a constructor for a class the java compiler builds a default constructor for that
class.

14. What is the default value of byte datatype in Java?Ans: Default value of byte datatype is 0.
15. What is the default value of float and double datatype in Java?Ans: For float its 0.0f and for double it’s 0.0d.

16. What is a static variable?Ans: Class variables also known as static variables are declared with the static keyword in a class, but
outside a method, constructor or a block.

17. What do you mean by Access Modifier?Ans: Java provides access modifiers to set access levels for classes, variables, methods and
constructors. A member has package or default accessibility when no accessibility modifier is
specified.

18. Variables used in a switch statement can be used with which datatypes?Ans: Variables used in a switch statement can only be a byte, short, int, or char.

19. What is the difference between StringBuffer and StringBuilder class?Ans: Use StringBuilder whenever possible because it is faster than StringBuffer. But, if thread safety is necessary then use StringBuffer objects.

20. What is finalize() method?Ans: It is possible to define a method that will be called just before an object's final destruction by the
garbage collector. This method is called finalize( ), and it can be used to ensure that an object
terminates cleanly.

No comments:

Post a Comment