Top 15 Java Interview questions and answers for freshers
Skip to main content

Top 15 Java Interview questions and answers for freshers

 

java interview question and answer, java mcq questions and answers, java interview questions and answers for freshers, java programming questions and answers pdf, java programming questions and answers for written test, java exam questions and answers pdf, java programming questions and answers, java programming mcq questions with answers, java interview programs for 5 years experience, java coding test questions and answers, core java programming interview questions and answers for experienced, java quiz with answers, java interview tests, java 8 test questions and answers


Top 15 Java Interview questions and answers for freshers

Top 15 Java Interview questions and answers for freshers:- In This Tutorial we discuss about Some of Important Java Question Which ask in interview. 

Question 1: What is the extension of java code file?

Answer- Java file have .java extension.


Question 2: What is difference between '==' and 'equals(....)' in  comparing the java string?

Answer: - When '==' operator for comparing then that point to the same object and if use 'equals(....)' that means that compare the actual string value. 

more read about operators topic visit here...


Question 3:- What are the various access specifier in java?

Answer:- Access Modifier in Java is provide a scope of a fieldsmethodsconstructor and class. there have four type of Access Modifier in Java.

1. Public  2. Private  3. Protected  4. Default

1. Public:- Public access modifier is used then you access everywhere. its scope it widest area of all other of modifiers.

2. Private:- if you use this modifier with variable, method and constructor then you can access in same class only. you cannot use outside of the class and package.

3. Protected:-  if you use this modifier with variable, method and constructor then you can access within class but outside of the package you can access in his child class.

Know more....


Question 4:- What is method overloading?

Answer:- When defined two or more method within the same class that's method name is same but their parameters are different. That case these methods is overloaded and this process is called Method OverloadingMethod overloading is support compile time polymorphismOverloaded methods have different return type. know more....

Question 5:- What is method overriding in java?

Answer:- When a method in a sub class has the same name and signature as a method of its super class. Then the method of sub class is overridden the method super class, that process is called Method OverridingMethod overriding support run time polymorphism. know more.....

Question 6:- What is use of final keyword?

Answer:- Final keyword is a non access modifier used for classattributes and method. If you use final keyword then that value is not changeable. Final keyword is use before of method then method does not override and use before a class then class is not inherited. Final keyword you used when you require that variable always store same value. for a example visit here


Question 7:- What is the purpose of static keyword?

Answer:- If we use static keyword before any variable and method then we access that method and variable in any class without create a object. Static keyword used for commonly to all the objects of the class. visit here


Question 8:- What is the constructor in Java?

Answer:- Constructor is a special type of method which name is same as class name and its used to initialize the object is called constructor. The constructor is directly called when class object is created. know more...


Question 9:- What is the new keyword?

Answer:- new keyword is used to create an instance of the class. It is used to allocate a memory for a new objects and returning a reference of that memory.

                     Test obj = new Test();

Question 10:- How Many types of constructor used in Java?

Answer:- 1. Default Constructor 2. Parameterized Constructor 3. Copy Constructor 4. Private Constructor


Question 11:- Can we override the  static method?

Answer:- No, We cannot override the static method.


Question 12:- Can we run a program without main method?

Answer:- Before JDK version 1.7  using the static block after this it is not possible.

Question 13 :- What is method? And types of method?

Answer:- function can be defined as set of statements that do a particular task.

Two type of functions use in java-

1. Pre defined Function:- this type of function is already defined in Java.

For example:- CharAt();

2. User Defined Function:- this type of function defined by the users and its name and types defined by users.

Syntax:-

function()

{

Set of Statements

......................

know more....


Question 15:- What is call by value and call by reference in methods ?

Answer:- Call by Value:- When you calling a function by value then you pass a variable or constants into method that is a actual parameters. These parameters are sent as formal parameters. If you any changes made by formal parameters will not reflect to actual parameters.

Call by Reference:- When you calling a method by references then you pass  a reference of variables into method. These passing parameters act as pointer variable. Any changes made by formal parameters will reflect to actual parameters.

Post a Comment

0 Comments