Home > Java > Interview Questions Answers
Interview Questions Answers

Top 10 Java Interview Questions Answers

1
Why is multiple inheritance not possible in Java?

It depends on how you understand "inheritance". Java can only "extends" one super class, but can "implements" many interfaces; that doesn't mean the multiple inheritance is not possible. You may use interfaces to make inheritance work for you. Or you may need to work around. For example, if you cannot get a feature from a class because your class has a super class already, you may get that class's feature by declaring it as a member field or getting an instance of that class. So the answer is that multiple inheritance in Java is possible.

Rating: 4.3/5 (3 votes cast)

Favorite
2
What is an abstract method?

An abstract method is a method whose implementation is deferred to a subclass. Or, a method that has no implementation.

Rating: 4.0/5 (2 votes cast)

Favorite
3
What is a static method?

A static method is a method that belongs to the class rather than any object of the class and doesn't apply to an object or even require that any objects of the class have been instantiated.

Rating: 4.0/5 (2 votes cast)

Favorite
4
What is Inheritance?

 Inheritance is the process by which one class (subclass) acquires the properties and behavior of another class (superclass).

Rating: 4.0/5 (2 votes cast)

Favorite
5
What is Java?

Java is an object-oriented programming language. Java language is originally developed by James Gosling at Sun Microsystems and released in 1995 as a core component of Sun Microsystems' Java platform. The language is derived much of its syntax from C and C++ but has a simpler object model and fewer low-level facilities. Java applications are typically compiled to bytecode (class file) that can run on any Java Virtual Machine (JVM) regardless of computer architecture that's why Java is called platform independent.

Rating: 5.0/5 (1 vote cast)

Favorite
6
Can you declare a class as private?

Yes, we can declare a private class as an inner class

Rating: 5.0/5 (1 vote cast)

Favorite
7
What is the difference between shallow copy and deep copy?

Shallow copy shares the same reference with the original object like cloning, whereas the deep copy get a duplicate instance of the original object. If the shallow copy has been changed, the original object will be reflected and vice versa.

Rating: 5.0/5 (1 vote cast)

Favorite
8
What invokes a thread's run() method?

After a thread is started, via its start() method or that of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

Rating: 5.0/5 (1 vote cast)

Favorite
9
What is Java Virtual Machine?

A Java Virtual Machine (JVM) is a self contained operating environment that behaves as if it is a separate computer. Java applets, for example, run in a JVM that has no access to the host operating system.

Rating: 4.0/5 (1 vote cast)

Favorite
10
What is the difference between method overriding and overloading?

Overriding is a method with the same name and arguments as in a parent, whereas overloading is the same method name but different arguments.

Rating: 4.0/5 (1 vote cast)

Favorite