Interview questions on JAVA

Mar 9 • Resources • 5224 Views • 2 Comments on Interview questions on JAVA

Interview questions on JAVA Constructor

 Interview questions on JAVA

1. WHAT DO YOU MEAN BY POLYMORPHISM ? Interview questions on JAVA Constructor

 

a. Polymorphism means the ability to take more than one form. it is an important object oriented programming concept.

for ex. let us consider the operation of addition, for two numbers the operand will generate a sum, for two strings it will produce a string by concatenation. And a real life example is carbon it can be used as charcoal and graphite.

 

2.WHAT DO YOU MEAN BY INHERITANCE.

 

 

Ans: .Java classes can be reused in several ways, which is done by creating new classes, resuming the properties of existing classes, this process of deriving a new class from an old class is called inheritance. Simply inheritance means inheriting the property of parent class by child class.

it is of four types:- Single

Multiple

Heirchical

Multilevel

3.WHAT IS OVERRIDDING IN JAVA ?

a. When a class defines a method using the same name, return type, and arguments as a method in its super class, the method in the class overrides the method in the super class. Methods may be overridden to be more public, not more private.

4.WHAT IS THE DIFFERENCE BETWEEN DECLARING A VARIABLE AND DEFINING A VARIABLE ?

Ans:. In declaration we just mention the type of the variable and it’s name. We do not initialize it. But defining means declaration + initialization    .Example: String s; is just a declaration while String s = new String (“abcd”); Or String s = “abcd”; are both definitions.

5.WHAT IS CONTRUSTOR OVER LOADING ?

 

Ans: Constructor overloading in java allows to have more than one constructor inside one class, and the constructor name should be same, and it is similar to polymorphism in java.

6.WHEN  DOES A DEFAULT CONSTRUCTOR COMES INTO ROLE ?

Ans: when a user don’t provide any constructor the user automatically creates a constructor, which is called the default constructor.

7.Can we make constructor STATIC? Placement Interview questions on JAVA Constructor
Ans: You cannot make a constructor as STATIC because if you use any access modifier in constructor compiler interprets it to be a method and expects a return type this class will not compile until you specify a return type since compiler thinks it to be a normal method bnot a constructor.

8. HOW  DOES A CLASS INHERIT THE CONSTRUCTORS OF ITS SUPER CLASS ?

A super default constructor is automatically available to the subclass when the subclass object is created. but if you want to access super class parameterized constructors we must use super keyword.

9.HOW MANY TYPES OF CONSTRUCTORS ARE THERE ?

1. Default constructor.

2. Parameterized constructor.

3.Aconstructor which can type arguments.

10. DO JAVA SUPPORT POINTER?

interview questions in JAVA for freshers

Interview questions on JAVA

Ans:. No java does not support pointers. Improper handling of pointers leads to memory leaks and reliability issues .

 

 

Tell us Your Queries, Suggestions and Feedback

Your email address will not be published.

2 Responses to Interview questions on JAVA

  1. kinga Wangmo says:

    How to add all the values entered in form and find the total value using java scripts.
    How to create links to our social media from website using html code.

  2. sakshi chaudhary says:

    Java is one of the most common and important that is asked by most of the companies during the interviews…here are some very important Question that will help you to understand the concept of the language in details…So have a look to enhance your knowledge..

« »