Skip to main content


Showing posts from March, 2017

Page VI - Java Interview Questions With Answers.

126. What Is The Difference Between An Interface & An Abstract Class?

Answer: 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.

127 .Can An Interface Extend Another Interface?

Answer: Yes an Interface can inherit another Interface, for that matter an Interface can extend more than one Interface.

128. If A Method Is Declared As Protected, Where May The Method Be Accessed?

Answer: A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

129. What Will Happen If Static Modifier Is Removed From The Signature Of The Main Method?

Answer: Program throws "NoSuchMethodError" error at runtime.

130. What Is The Default Value Of An Object Reference Declared As An Instance Variable?


Page V - Java Interview Questions With Answers.

101. What's The Difference Between Constructors & Other Methods?

Answer: Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

102. Is There Any Limitation Of Using Inheritance?

Answer: Yes, since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation.

103. When Is The ArrayStoreException Thrown?

Answer: When copying elements between different arrays, if the source or destination arguments are not arrays or their types are not compatible, an ArrayStoreException will be thrown.

104. Can You Call One Constructor From Another If A Class Has Multiple Constructors?

Answer: Yes, use this syntax.

105. What's The Difference Between The Methods Sleep & Wait?

Answer: The code sleep2000; puts thread aside for exactly two seconds. The code wait2000, …

Page IV - Java Interview Questions With Answers.

76. What Is Function Overriding?

Answer: If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding.

77. Difference Between Overloading & Overriding?

Answer: Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class parameter must be different in case of overloading, parameter must be same in case of overriding.

78. What Is Final Class?

Answer: Final classes are created so the methods implemented by that class cannot be overridden. It can’t be inherited.

79. What Is NullPointerException?

Answer: A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc.

80. What Are The Ways In Which A Thread Can Enter The Waiting State?

Answer: A thread can enter the waiting state by invoking its sleep method, by blocking on IO, by u…

Page III - Java Interview Questions With Answers.

51. What Is An Interface?

Answer:  An interface is a collection of abstract methods. A class implements an interface, thereby
inheriting the abstract methods of the interface.

52. Give Some Features Of Interface?

Answer: Some features of interfaces are:
Interface cannot be instantiatedAn interface does not contain any constructors.All of the methods in an interface are abstract.
53. Define Packages In Java?

Answer: A Package can be defined as a grouping of related types, classes, interfaces, enumerations and annotations providing access protection and name space management.

54. Why Packages Are Used?

Answer: Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations, etc., easier.

55. What Do You Mean By Multithreaded Program?

Answer: A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines…

Page II - Java Interview Questions With Answers.

26. According To Java Operator Precedence, Which Operator Is Considered To Be With Highest Precedence?

Answer: Postfix operators i.e [] . is at the highest precedence.

27. Variables Used In A Switch Statement Can Be Used With Which Data Types?

Answer: Variables used in a switch statement can only be a byte, short, int, or char.

28. When parseInt Method Can Be Used?

Answer: This method is used to get the primitive data type of a certain String.

29. Why Is String Class Considered Immutable?

Answer: The String class is immutable, so that once it is created a String object cannot be changed. Since String is immutable it can safely be shared between many threads ,which is considered very important for multithreaded programming.

30. Why Is StringBuffer Called Mutable?

Answer: The String class is considered as immutable, so that once it is created a String object cannot be changed. If there is a necessity to make a lot of modifications to Strings of characters then StringBuffer should be used.

31. Wha…

Page I - Java Interview Questions With Answers.

1. What Do You Know About Java?

Answer: Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

2. What Are The Supported Platforms By Java Programming Language?

Answer: 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.

3. List Any Five Features Of Java?

Answer: Some features include:
Object Oriented.Platform Independent.Robust.Secured & Dynamic.Multi-threaded.
4. Why Is Java Architectural Neutral?

Answer: It’s compiler generates an architecture-neutral object file format, which makes the compiled code to be executable on many processors, with the presence of Java runtime system.

5. How Java Enabled High Performance?

Answer: Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java byt…