Java Interview questions with answers

Java Interview Questions with Answers for Freshers Beginners

Java Interview Questions Part B

Q. Java Interview questions and answers for freshers’ most asked java interview questions

Q. What is meant by the program?

A program is a set of instructions, which are executed by a machine to reduce the burden of a user or a human being by performing operations with speed and ease without any mistakes

Q. What is a programming language?

It is a communication channel between user and user through a computer.

For an example, human beings can communicate with each other in different language like Hindi, English etc. whereas to interact or to communicate with a computer, programming language was needed.

In The same way if we want to interact/communicate with the computer we need communication channel that is called programming language

Q. How many types of programming language?

There are 3 types.

i) Machine/binary language

ii) Assembly language

iii) High-level language

Q. What is meant by software?

It is a set of programs, which can perform multiple tasks.

Q. How many types of software?

Software’s are classified into 2 types.

i)  System software.

ii)  Application software.

Q. Explain about system software?

The software’s which are designed to interact or communicate with hardware devices and make them to work are called as system software.
These software’s are generally developed in languages like c, c++, etc

Q. Explain about application software?

The software’s which are designed to store data, provide entertainment, process data, do business, generate reports etc. are called as application software. These softwares are generally developed in languages like java, .net, etc.

The application software’s are further classified into 2 types.

                 a) Stand Alone  Software: The software which can execute in the context of a single machine is called  standalone software
Example: MS-Word, media player, etc.

                b) Web Based Software: The software which can execute on any machine in the context of a browser is called web based software.
Example: Gmail, Facebook, etc.

Q. Who introduced java language?

            The java language was introduced by SUN Micro Systems in the year 1995 in three editions.

i) JSE (Java Standard Edition)

This edition can be used to develop standalone software.

ii) JEE (Java Enterprise Edition)

This edition can be used for developing web based software.

iii) JME (Java Mobile Edition)

This edition can be used for developing applications for mobile devices, wireless devices, embedded controllers etc. where memory is limited.

Q. What is Machine level language?

                1st type of computer language which is a machine dependent language which also termed as Binary language. This language is a combination of  0’s and 1’s

Q. What is Assembly language?

               To overcome the hard coding of machine language, programmers introduced a new language called assembly language.

Q. What is the High-level language?

             It is very difficult to understand assembly language, to remember all mnemonics. To overcome this  problem, programmers introduced High level language in 1957.

The first high level language introduced by IBM, for scientist and engineers.

Q. Features of java?

            The features of any programming language comprises of services or the facilities provided by that language. The various features of java language are

Simple, Object Oriented, Secured, Distributed, Platform Independent, Interpreted, High performance, Portable, Multithreaded, Dynamic, Robust

Q. What is Procedure Oriented Approach?

              In this process, we use functions to perform task. When the programmer wants to write a program, first he will divide the tasks into subtasks. Each and every task is expressed as a function.

 All these functions are controlled by main function.

Q. What is Object Oriented Programming Language?

            A language which is developed by using object oriented principles  is called object oriented programming language.

Q. Principles of Object Oriented?

i) Class

ii) Object

iii) Encapsulation

iv) Abstracion

v) Inheritance

vi) Polymorphism

Q. What is Class?

It is an imaginary thing .It provides full information related to Object. In java ,we can develop classes with the help of class keyword .

Every class keyword is followed by class name and it should be ended with open and closed { , }.

Example student: 

            class Student{

                  int sid;

                   string sname;

                    int sage;

               void read(){

                  }

              Void write (){

              }

               }

Q. What is Object?

           It is a real word existing thing, each and every object having 3 characteristics.

i) Identity.

ii) properties.

iii) Functionalities.

Q. What is  Encapsulation?

            It is a process of binding the variables and methods into a single entity.

Example: Student program in Encapsulation

 Class Student
{

Int rollNo;

Double marks;

String name;

Void display(){

System.out.println(“RollNo: +rollNo”);

System.out.println(“Marks: +marks”);

System.out.println(“Name: +name”);

}

Public static void main(String[] ar){

System.out .println(“Student information”);

Student st=new Student();

st.display

}

}

Q. What is Abstraction?

            Hiding the implementation logic and providing only specification. With the help of one keyword  “abstract”.

Syntax :

Interface InterfaceDemo

{

abstract void m1();

abstract void m2();

}

Q. What is Inheritance?

           Inheritance is a concept of acquiring the members from one class to another class.

Using inheritance we can achieve reusability, there by reducing the code size and development time of the application.

Various types of inheritance in Java are

i) Single level inheritance.

ii) Multiple inheritance.

iii) Multilevel inheritance.

iv) Hierarchical inheritance.

v) Hybrid inheritance.

Note: Java language supports 2 types of inheritance.

Q. What is Polymorphism?

                If a single entity shows multiple forms or multiple behaviors, then it is called as polymorphism.  Using polymorphism we can achieve flexibility , where a single entity can perform different operations according to the requirements.

Polymorphism is classified into two types and they are.

i) Compiler Time Polymorphism.

ii) Run Time polymorphism.

Q. Explain about  JVM architecture?

        JVM was abbreviated as  Java Virtual Machine.

JVM architecture
Q. Explain about Data types?

           The data types represents the types of data that we store into the memory. The datatypes in java language are classified into 3 types.

i) Primitive datatypes

ii) Derived datatypes

iii) User defined datatypes

Q. What is variable?

A variable is a memory location where we can store some data.

variable is a memory location java interview questions

Variable declaration: The process of specifying what type of data is stored into the memory is called as variable declaration.

Q. What is keyword?

         The words that have predefined meaning in java or the words whose meaning in reserved in java are called keywords

The keywords of java language must be specified in lowercase only

Q. What is literal?

       The values that we store into a variable are called as literals

Q.What is Operator?

           Any symbol that performs an operation will be called as operators.

Q. What is Operand?

     The values on which the operations are performed are called as operands.

What is Operand java interview questions

Q. What is meant by new operator?

        New operator is used to create object. Creating an object means allocating memory for a class in heap memory.

Class Student 

{

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

}

Student stu=new Student ();

Stu is called as the reference variable. It is used to refer or point to an object. The name of the reference variable can be any valid java identifier.

Q. Explain Control Statements?

The statement of a java program will be executed in sequential order. If we don’t want to execute the statements in sequential order or if we want to execute the statements in random order according to programmer choice, then we use  control statements.

The control statements are classified as following

a) Conditional statements

b) Iterating statements

c) Transfer statements

Q. Explain Conditional Statements?

         Two types of conditional statements. They are

a) If else statements

b) Switch statements

If-else statements: If else statements can be used to execute  a group of statements based on a condition.

Syntax:

If(condition)

{

       Statement 1;          if block

}

else

{

         Statement 2;     else block

}


Example Numbers:

Class ifElseDemo

{

Public static void main(String[] args){

Int n=89;

If(n%2==0)

{

System.out.println(“Even number”);

}

else

{

System.out.println(“Odd number”);

 }

}

 }

Q. Explain switch statement?

The switch statements can be used  to execute a group of statements based on a value.

Syntax :

Switch(arguments)

{

Case label1: statement 1;

           Break;

Case label2: statement 2;

          Break;

Default : default statements;

}

Example Switch:

      Class SwitchDemo

{

       Public static void main(String[] args){

Intch=2;

Switch(ch)

{

 Case 1: System.out.println(“first choice”);

                          Break;

Case 2: System.out.println(“second choice”);

                          Break;

Case 3: System.out.println(“third choice”);

                          Break;

Case 4: System.out.println(“fourth choice”);

                          Break;

default: System.out.println(“wrong choice”);

}

}

}

Q. Explain about Iterating statements?

Iterating statements are four types.

i) for loop

ii) while loop

iii) do-while loop

iv) for each loop

for loop: This loop can be used for executing the statements multiple times. for loop has to be used when we know the exact number of iterations.

Syntax:

For(initialization;condition;increment/decrement)

{

                                 Statements;

}

Example Forloop:

Class ForDemo

{

Public static void main(String[] args){

Int n=6;

For(int i=1;i<=10;i++)

{

System.out.println(n+”+”+i+”=”+(n*i));

}

}

}

Q. Explain while loop?

While loop can be used to execute statements in multiple times. A while loop was used when we do not know the exact number of iterations.

Example While loop:

Class WhileDemo

{

Public static void main(String args[])

{

Int  n=8,i=1;

While(i<=10)

{

System.out.println(n+”*”+i”=”+(n*i));

i++;

}

}

}

Q. Explain Do-while loop?

This loop can be used to execute the statement multiple times. A Do-while loop was used when we do not know the exact number of iterations.

Syntax :

Do{

Statements;

}

while (condition);

Example Dowhile:

Class DoWhileDemo

{

Public static void main(String args[])

{

Int n=9,i=1;

Do{

System.out.println(n+”*”+i+”=”+(n*i));

i++;

}

while(i<=10);

}

}

Q. Difference between while loop and do-while loop ?

->  In a while loop, the statements were executed after evaluating the condition, where as in a do-while loop the statements were executed before evaluating the condition.

-> In a while loop, if the condition is false for the first time, then the statements will not execute where as in a do-while loop if the condition is false for the first time then the statements will execute for one time.

-> In a while loop, the statements were executed for the first time or more times, where as in a do-while loop the statements were executed for first time or more times

Q. Explain Nested loop?

If we specify a loop inside another loop then it is called as nested loop. Any loop can be specified inside any other loop any number of times.

Example Nestedloop:

Class NestedForDemo

{

 Public static void main(String[] args){

For(int i=1;i<=5;i++){

For (int j=1;j<=5;j++){

System.out.println(“*”);

}

System.out.println();

}

}

}

Q. Explain Transfer statements?

         Three types of transfer statements.

i) Break

ii) Continue

iii) Return

Break: Break is a transfer statement which can be used either inside switch statements or inside a loop.

-> Break statement, when we use switch, it will transfer the control from inside the switch to outside the switch, so that we skip the execution of removing cases.

-> Break statements , when used in loop it will transfer the control from inside the loop to outside the loop, so that we can skip the execution of remaining iterations.

Example Break:

Class BreakDemo
{

Public static void main (String [] args)

{

Int sum=0, capacity=15;

For (int i=1;i<=100;i++){

Sysout.out.println(i);

Sum=sum+I;

If(sum>=capacity)

Break;

}

Sysout.out.println(sum);

}

}

Q. What is Continue?

Continue is a transfer statement which has to be used only in loops. The continue statements will skip the current iteration and continues with the remaining iterations.

Example

Class ContinueDemo

{

Public static void main(String [] args){

For(int  i=1;i<=20;i++){

If(i==7|i==13)

Continue;

System.out.println(i);

}

}

}

Q. Explain about pointers in java?

Java does not support pointers. The reasons are:

Pointers always represent address. If we know the address, we can easily access the data which states that there is no security.

Adding of pointers will leads to program crash, means program will be abnormally terminates.

With the help of the pointers, we can develop virus programs and hacking programs.

Q. What is Garbage collection?

In java, to allocate memory we need to write some external code

But if we want to deallocate memory no need to write external code like destructors.

Java internally provides one demon thread to de allocate memory.

Q. Explain platform independency?

Java is platform independency language. Platform independency means developing any program under one operating system, compile the same programs under the same operating system and executing program in different operating system.

Q. What is most important feature in java?

Platform independency

Q. What is Architectural neutral?

If we develop and compile any program under one processor, executing  same program in different processor is called Architectural neutral

Q. What is portable?

The combination of platform independency and architectural neutral is called portable.

Q. What is Multithreaded?

Thread represents an individual process to execute group of statements.

-> JVM uses several threads to execute different blocks of code creating multiple threads

Q. Explain about interface?

If we don’t know any implementation, then we can go for interface. Interface contains only abstract methods.

In java, we can develop interface with the help of one keyword called interface.

Interface keyword always follows by interface name.

Syntax:

Class A implements InterfaceDemo

{

Public void m1()

{

   }

Public void m2()

{

   }

Public static void main(String [] args)

{

InterfaceDemo id= new A();

}

}

Q. What is single level inheritance?

In java each and every class is the sub class of object. If we design any single class in java that  automatically comes under single level inheritance.

Example

  Class One

{

Intx=12;

Void show()

{

System.out.println(“one class show”);

}



Class Inheritnce

{

 Public static void main(String [] args){

One c=new One ();

System.out.println(c.x);

c.display();

}

}

}

Q. Explain multilevel inheritance?

Making a relationship between two classes is called multilevel inheritance.

Example

Class One

{

Int x=12;

Void show()

{

System.out.println(“one class show”);

}

}

Class Two extends One

{

Int y=23;

Void display()

{

System.out.println(“two class display”);

}

}

Class Inheritnce

{

 Public static void main(String [] args){

 Two c=new Two();

System.out.println(c.y);

c.display();

}

}

Q. What is Hierarchical inheritance?

In this inheritance, we have only one superclass and multiple subclasses.

Syntax:

Class A
{

 }

Class B extends A

{

}

Class C extends A

{

}

Class D extends A

{

}

Q. What is Method Overloading?

The process of specifying multiple methods, having different signature with same method name is called as method overloading.

Method signature

     The method signature include 4 parts, they are

–> Method Name

–> Number of parameters.

–> Types of parameters.

–> Order of parameters.

Example

  Class Addition 
{

     Void add(int x, int y)
{

System.out.println(“result1: +(x+y)”);

}

 Void add(int x, inty,int z){

System.out.println(“result2: +(x+y+z)”);

}

     Void add(int x, double y){

System.out.println(“result3: +(x+y)”);

}    

Void add(double x, int y){

System.out.println(“result4: +(x+y)”);

}

Public static void main(String[] args){

Ad.add(3,4);

Ad.add(3,4,5);

Ad.add(3,4.5);

Ad.add(3.5,4);

}

}

Q. Why should be implement method overloading?

We implement method overloading to provide flexibility to the user so that, the user can use one method to perform different operations according to the requirement.

         Method overloading can be applied to instance methods, static methods or both and even to main method

Q. What is method overriding?

The process of specifying two methods with same signature and same return types for two different classes that have IS-A relationship is called as method overriding.

Example:

Class Parent
{

Void msg()
{

System.out.println(“Fdaytalk”);

}

}

Class Child extends Parent

{

Void msg()

{

System.out.println(“Career Point”);

}

}

Class Polymorphism

{

Public static void main(String[] args)

{

Parent p= new Parent();

p.msg();

Child c= new Child ();

c.msg();

Parent p1= new Child ();

P1.msg();

}

}

Q. Why should we implement method overriding?

If the child class does not want parent class method implementation, then the child class will override that method to provide new implementation.

                The method overriding can be applied to only instance methods, if the same concept is applied to static method then it is called as method overriding

Q. What is keyword?

Keyword will refer to current instance of a class.

Using  keyword, we can access instance members of a class.

Specifying ‘this’ keyword, sometimes optional and sometimes mandatory.

Example

Class Sample

{

Int a=11;

Int b =22

Void show ()

{

Int b =33;

Int c= 44;

System.out.println(this.a);

System.out.println(this.b);

System.out.println(b);

System.out.println(c);

this.msg();

}

Public static void main(String[] args)[

Sample s=new Sample();

s.show();

}

}

Q. What is super keyword?

The super keyword is used to access instance members of parent class.

           Specifying the super keyword, sometimes optional and sometimes mandatory. The compiler can never specify super keyword. Super keyword works for only one level  i.e. only its parents class members

Q. Defining casting?

Converting from one data type to another data type is called casting, these are 2 types.

–> Implicit casting

–> Explicit casting

Implicit casting: Converting from smaller data types to higher data types is called implicit casting

Explicit casting: converting higher data types values to lower data types values is called explicit casting

Q. What is Arrays?

Arrays is a reference data types which provide some fixed memory locations. In those locations we can hold more than one value with same data type values.

Arrays in java language are classified into two types, they are

–> Single dimension array

–> Multidimensional array

Single dimension array: Single dimension array is a collection of multiple values represented in the form of a single row or single column.

Example

Class WrapperDemo

{

Public static void main(String[] args)
{

Int a[] = {10,20,30,40,50};

System.out.println(“Elements from a array”);

For(int i=0;i<a.length;i++){

System.out.println(a[i]);

}

Q. Difference between length field and length ()?

Length field: It is used to calculate the size of an array. Size means the no of elements present in the array or the no of elements we are going to be placed into the array.

Length (): It is used to calculate no of characters available in string reference variable

Q. What is multi-dimensional arrays ?

The multi dimension arrays in java will be represented in the form of array of arrays.

The syntax for declaring a two-dimensional array:

Datatype arrayName[][];

Q. Explain jagged array ?

If multi dimension array of the arrays have unequal size then they are called jagged array.

Example

 Class ArrayDemo
{

Public static void main(String [] args)

{

Intarr[][]={{1,2,3},{4,5,6},{7,8,9}};

For(int i=0;i<arr.length;i++)

{

For (int j=0;j<arr[i].length;i++)

{

System.out.println(arr[i][j]+””);

}

System.out.println();

}

For(int[]x:arr)

{

For(int y:x)

{

System.out.print(y+””);

}

System.out.println();

}

}

}

Q. What is Annoy array?

Not declared any variable.

Example

Public class ArrayDemo
{

Static  void m1(int a[])
{

Int count=0;

For(int i=0;i<a.length;i++)

Count=count+a[i];

}

System.out.println(Count);

Public static void main(String[] args)
{

m1(new int[] {10,20,30,40});

}

}

Q. Explain variable concept?

Variable is a named memory location which can hold the data temporarily and the data may be changed from one statement to another statement.

Variable can be classified into 2 types.

–>Primitive variable

–>Reference variable

Primitive variable: A variable which can be declared with the help of primitive data type  is called primitive variable.

These can be classified into 3 ways.

Static variable: A variable which can be defined with the help of static keyword is called static variable.

Syntax:

Static int a ;

Static int a=11;

Instance variable: if a variable is declared inside the class and outside the methods and outside the constructors, then it is called as instance variable.

Local variable: if a variable is declared inside the class and inside the method or inside the constructor, then it is called as local variable.

NOTE: ‘this’ keyword should not be applied to local variable.

Q. Explain constructor?

Constructor is a block, which is used for initializing the instance variables.

–> The name of the constructor must be same as that of the class name.

–> Constructors should not have any return type, not even void.

–> The constructor will be executed during the object creation time.

–> The constructor will executed one time for every object that is created.

Based on number of parameters, the constructors are classified into two types.

–> Zero parameterized constructor

–> Parameterized constructor.

Zero parameterized constructor: if a constructor does not have any parameters, then it is called as zero parameterized constructor.

Syntax:

Class ClassName 
{

ClassName(){

}

}


Parameterized constructor: If constructor contains some parameters, then it is called as parameterized constructor. A parameterized constructor can contain any number of parameters and it can be separated by comma.

Syntax:

Class ClassName
{

ClassName(list of parameters){

}

}

Q. Explain typecasting?

It is a process of converting a value from one type to another type.

If the values are same type, then we do not require any typecasting. Typecasting has to be performed if the values are different type and if they are compatible.

Typecasting can be performed in the following two types.

-> Typecasting with respect to primitive types.

-> Typecasting with respect to reference types.

Widening: It is a process of converting a value from smaller primitive type to bigger primitive type.

Narrowing: It is a process of converting a value from bigger primitive type to smaller primitive type.

Upcasting: If a child class object is referred by parent class reference, then it is called as Upcasting.

Downcasting: If the parent class object is referred by child class reference, then  it is called down casting.

Q. Why we are not allowed to instantiate an abstract class?

Assume we are allowed to create an object of abstract class, using that object if we invoke a concrete method then, it will be executed because it contains definition, but using that object if we invoke an abstract method then , it will lead to an unsafe operations because it does not contain any definition.

To avoid the unsafe operations, we are not allowed to instantiate an abstract class.

Q. Why should be declared method as abstract?

A method should be declared as abstract, when we want a method to be implemented by different programmers with different logics.

Q. Why should we declare a class as abstract even though it doesn’t contain any abstract methods?

We declare the class as abstract even though it does not contain any abstract methods because when we don’t want an object of our class to be created by declaring the class as abstract

By this, we restricting has-a relationship and forcing to use is-a relationship

Q. Explain packages?

Packages are a special folders which is a combination of classes, interface, enum and also its sub packages.

Packages provide security, can be classified in 2 ways.

–> User defined packages.

–> Predefined packages.

Q. What are Access modifiers?

Accessibility modifiers will provide permission for developer to use variable, methods.

In java, we have 4 types of accessibility modifiers.

–> Private

–> Default

–> Protected

–> Public

Q. Explain import statement?

Import statements are used to provide information about classes from one package to another package.

Import statements are 2 types.

–> Normal import statement

–> Static import statement.

Q. Difference between import statements and #include statements?

With the help of #include statements, predefined code is copied into our ‘C’ program.

Import statement will not copy any code, it just provide response to our java program. Importing the single class at a time or importing the multiple classes at a time.

Q. Define wrapper classes?

Representing primitive data in the form of object or class is called wrapper class.

Each and every primitive data type having its own wrapper class

Q. What is auto boxing and auto unboxing?

–> Converting from primitive data type to wrapper class object directly is called auto boxing.

–> Converting from wrapper object to primitive variable is called auto unboxing.

Q. What is cloning?

Creating new object with updated values is called cloning.

In the cloning, object addresses are different but content is same in both objects.

Q. Explain inner classes?

Writing a class with in another class is called inner classes.

Inner classes are introduced for event handling purpose. There are four types of  inner classes.

–> Normal inner class

–> Static inner class

–> Method level inner class

–> Anonymous inner class

Q. What is exception handling?

Exception is an event which can be raised by JVM due to the problem of logic at run time.

Syntax:

Class ExceptionDemo {

Public static void main (string [] args){

String s=args [0];

}

}Q. What is error?

It is an event which can be raised by the JVM due to the problem of JVM failure and lack of system resources which are not recoverable.

Q. What is reflection?

It is a process of examining or introspecting the information of a class during execution time. All the classes and interfaces related to reflections are available in java.lang .reflect packages.

Q. What is enum keyword?

The enum keyword is introduced in java 1.5 version and it is designed to create a group of named constants.

Syntax

Enum<enumName>

{

 Constants

}

Q. What is collection object?

An object is said to be a collection object if it holds or stores group of other objects.

All the collection classes are classified into 3 categories.

1) List

2) Set

3) Map.

List: This category can be used to store group of individual elements where the elements can be duplicated

List is an interface which cannot be instantiated and therefore we take the help of the implementation classes. The implementation classes of list interface are Arraylist, linked list, vector and stack.

Set: This category can be used to store  group of individual elements where the elements can be duplicated.

Set is an interface which cannot be instantiated and therefore we take the help of the implementation classes. The implementation classes of list interface are Hashset, linkedhashset and treeset.

Map: This category can be used to store the elements in the form of key-value pairs where the keys cannot be duplicated but the values can be duplicated.

Map is an interface  which cannot be instantiated and therefore we take the help of the implementation class. The implementation classes of map interface are Hashmap, linkedhashmap, treemap and hashtable.

Q. What are cursors of collection framework?

The cursors available in java until packages can be used for accessing the element one by one and perform some other operations, there are 3 cursors and they are:

–> Iterator

–> Listiterator

–> Enumeration

Q. What are generics?

Generics concept introduced in the java 1.5 version. Generics are called as parameterized type. The generics are represented by a pair of angular brackets (<>), called as diamond operator.

Q. Defining isostreams?

A stream represents a sequential flow of data from one location to another location.

The streams that are used to perform input and output operations are called as isostreams. These streams are classified into two types and they are

–> Byte streams

–> Character streams

Byte streams: The streams which perform  operations byte by byte are called  byte streams.

Character streams: The streams which perform  operations character by character are called as character stream.

What is serialization?

It is a process of converting an object into a stream of bytes.

Q. What is deserialization?

It is a process of converting a stream of byte into objects.

Q. What is scanner?

Scanner class is introduced in java 1.5 version and it is available in java .until package. It can be used for reading contents from any resource. The scanner class provides methods using which we can read any type of data without performing parsing.

Q. What is console?

Console class is introduced in java 1.6 version and it is available in java.io package. This class can be used to read contents from the keyboard. Console class is available in java .io package.

We cannot create an object of console class directly and it can be created by using console () available in system components.

Q. Difference between extends thread and implements runnable?

When we create a thread by extending thread class, then we do not have a chance to extend from another class whereas when we create a thread by implementing runnable interface, then we have a chance to extend from another class.

Q. What is thread synchronization?

When multiple threads want to access the same object at the same time and giving access to only one of the thread is called synchronization.

Thread synchronization can be done in two ways.

–> synchronized block

–> Synchronized method

Q. What is deadlock?

When a thread holds a resource and waits for another resource to be released by second thread, the second thread holding a resource and waiting for a resource to be realized by first thread, then in such case both threads will be waiting and they never execute. It is called deadlock.

Q. What is externalization?

If we want to do serialization, everything is taken by JVM. In the deserialization also every control is in the hands of JVM. There is no programmer control. If we are doing the serialization, each and every data is going to be serialization and every data is going to de deserialization.

Q. What are factory methods?

A method which returns same class object or any other class object is called factory method.

They are two types:

i) Static factory method,

ii) Non-static factory method.

Q. What is thread?

A thread represents a separate path of execution of a group of statement. In a java program, we have group of statements, these are executed one by one statements by JVM. This is called thread.

Q. What is inter thread communication?

In java, one thread is going to communicate with other thread with the help of wait (), notify (), notify all ().
If any thread is executed, that thread is having the lock on that resource.

Q. What is JDK?

JDK means Java Development Kit. It is the tool necessary to compile, document and package Java programs. Along with JRE, it includes an interpreter, a compiler andjar a documentation generator and other tools needed in Java development. It contains JRE + development tools.

Q. What is JRE?

JRE was abbreviated as Java Runtime Environment. JRE refers to a runtime environment in which java byte code can be executed.

Q. What is JVM?

JVM was abbreviated as Java Virtual Machine. It is an abstract machine. It is a specification that provides run-time environment in which java byte code can be executed.

Q. Define multiple inheritances?

If a child class inherits the property from multiple classes is known as multiple inheritances.

Java does not allow extending multiple classes. The problem with multiple inheritances is that if multiple parent classes have the same method name, then at runtime it becomes difficult for the compiler to decide which method to execute from the child class. Therefore, Java doesn’t support multiple inheritances.

Learn More:  Part I- Java collections Interview Questions

Related Search

java basic interview questions and answers, java oops concepts interview questions, java collections interview questions, commonly asked java interview questions, frequently asked java interview questions, java basic interview questions, core java interview questions for experienced, top core java interview questions, java interview questions for 1 years experience, core java interview questions and answers for experienced, java interview questions and answers for freshers, java core java interview questions, java interview questions for freshers, java interview questions with answers, online java interview questions and answers, complete java interview questions and answers for freshers, pdf download java interview questions and answers, study java interview questions and answers experience, fresher and beginners java interview questions and answers, collection of java interview questions and answers, most commonly asked java interview questions and answers, repeatedly asked java interview questions and answers in interviews, most imp java interview questions and answers in HR

Comments

2 thoughts on “Java Interview questions with answers”

10 Best Building Games on PC in 2024 Review: Why Buy Lava Blaze Curve 5G? Sale is Live! Review: Why Buy boAt Stone Spinx Pro? New Portable Speaker Xiaomi 14 Series Debuts in India, starting at ₹59,999 Best Wireless TWS Earbuds: Up to 75% Off Deals