40 Most important Java interview questions topic wise:
Question 1: Implement a stack using array.
Question 2: Implement a stack using Linked List :
Question 3: Implement a stack using two queues .
Question 4 : Sort an stack using another stack
Linked List :
Question 5 : Implement singly linked list in java.
Question 6: How to reverse…[Read more]
• Arrays in Java are objects, created with the new operator.
• Unordered arrays offer fast insertion but slow searching and deletion.
• Wrapping an array in a class protects the array from being inadvertently altered.
• A class interface is composed of the methods (and occasionally fields) that the class user can access.
• A class int…[Read more]
How to Increase size of array once defined?
Java includes a class called Vector that acts much like an array but is expandable. This added capability comes at the expense of some loss of efficiency. You might want to try creating your own vector class. If the class user is about to overflow the internal array in this class, the insertion…[Read more]
What is NullPointerException?
A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc.
Explain public static void main (String args[ ])
public − it is the access specifier.
static − it allows main() to be called without instantiating a particular instance of a class.
void − it affirns the compiler that no value is returned by main().
main() − this method is called at the beginning of a Java program.
String args[ ] − args para…[Read more]
Q.no2.—> Does Java support multiple inheritance ?
Ans.—–> No, Java does not support multiple inheritance. Each class is able to extend only on one class, but is able to implement more than
Can you access non static variable in static context ?
A static variable in Java belongs to its class and its value remains the same for all its instances. A static variable is initialized
when the class is loaded by the JVM. If your code tries to access a non-static variable, without any instance, the compiler will
complain, because those…[Read more]
Q1.—> What does the “static” keyword mean ? Can you override private or static
method in Java ?
Ans—-> The static keyword denotes that a member variable or method can be accessed, without requiring an instantiation of the class to
which it belongs. A user cannot override static methods in Java, because method overriding is based upon dyn…[Read more]