Java Interview Questions and Answers for Freshers Pdf - 2

Question: 6

What are the rules we have to follow in overloading?

The number of arguments must be different.

The type of arguments must be different

It will not depend on return type.

Question: 7

What is an abstract method?

An abstract method is a method whose implementation is deferred to a sub class.

Question: 8

What is the difference between an abstract class and an interface?

An abstract class allows its subclasses to override the methods defined in it.

It is never instantiated and a class can inherit from a single class, as Java doesn’t support for Multiple Inheritance.

It may contain both abstract and non abstract methods.

An interface has public, abstract methods and may have public, static and final variables.

It introduces multiple inheritance by a class implementing several interfaces.

Question: 9

What is the difference between an argument and a parameter?

While defining method, variables passed in the method are called parameters.

While using those methods, value passed to those variables are called arguments.

Question: 10

What is the difference between overloading and overriding?

In overloading, there is a relationship between methods available in the same class whereas in overriding, there is relationship between a superclass method and subclass method.

Overloading does not block inheritance from the superclass whereas overriding blocks inheritance from the superclass.

In overloading, separate methods are same name whereas in overriding, subclass method replaces the superclass.

Related Questions