0% found this document useful (0 votes)
2 views

Interview Q Answer Core Java From Youtube Video (AutoRecovered)

The document consists of a series of interview questions and answers related to core Java concepts, including access specifiers, encapsulation, polymorphism, abstraction, interfaces, and collections. It also covers topics such as exception handling, multithreading, and the differences between JDK, JRE, and JVM. Additionally, it explains various Java features like method overloading, method overriding, and the singleton design pattern.

Uploaded by

bhamrekashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

Interview Q Answer Core Java From Youtube Video (AutoRecovered)

The document consists of a series of interview questions and answers related to core Java concepts, including access specifiers, encapsulation, polymorphism, abstraction, interfaces, and collections. It also covers topics such as exception handling, multithreading, and the differences between JDK, JRE, and JVM. Additionally, it explains various Java features like method overloading, method overriding, and the singleton design pattern.

Uploaded by

bhamrekashyap
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 14

0 Interview Q Answer Core java from YouTube Video

1)what is access specifier in in java avaible in java


Ans=there are 4 types specifier in java those are public,
private, protected, defulater.

2)what is encapsulation
Ans= encapsulation mean we bind code and data in single
specifier is called encapsulation.
For Example, =we can take capsule that we mix several
medicines in one capsule that is encapsulation

3) what is polymorphism
Ans= polymorphism is one task and many forms
For example we can take human like man at a home man can
be as father plays roles son and as husband and same
persona if go in shop his plays role as a customer
Polymorphism has two types
First one is runtime polymorphism and second one is compile
time polymorphism.
By using overriding we can achieve runtime polymorphism
And using method overloading method we can achieve
compile time polymorphism.
4)what is abstraction.
Ans= hiding the implementation details of a code and
exposing only the necessary information to the user
For example if u sending SMS to anyone but internal process
not see just only the main process show to user user don’t
know about internal process.

5)what is a interface
Ans=an interface cannot have constructors because we
cannot create object of an interface.
If you want a class to achieve multiple inheritance ,there is
only one way interface.
If an interface is made private, or if the methods in it are
made private or protected ,then a compilation error will be
throw
Interface can be used to achieve loose coupling
terfaces provide a way to achieve abstraction and multiple
inheritance in Java, allowing classes to share common
method signatures without being tightly coupled.
Interface is type of class and also reference type of java.
Interface contains public static final variables and abstract
method. main Purpose of Interface.... 1- once you defined
interface than we used any where in the application. 2- in
inheritance we can not define multiple inheritance using
class, but by using interface we can define multiple
inheritance.
6)what is string buffer class
1. String Buffer objects are mutable, meaning that you can
change the contents of the buffer without creating a new
object.

4) what is String builder


Ans=string builder comes in java jdk1.5 after java become in
advance that time String builder came and its is more use full
than the buffer
6)Overloading
Imp=When two or more methods in the same class have the
same method name but different parameters, this is called
overloading
Method overloading is a compile-time polymorphism

5)Method overriding.
Imp=in overriding method should be same. parameter should
be same.
Ans=When two or more parameter or more name are same
but they have also same parameter is called as overriding.
Ans= means when we have same name but different
parameter is called as overloaded.

7)overriding.
occurs when a subclass (child class) has the same method as
the parent class.
Overriding is solving runtime time polymorphism

8) what is hibernate
Ans= hibernate use for retrieving data and answer data into
the database.

9)what spring boot


Ans=

10) what is class


Ans= A class in Java is a set of objects which shares common
characteristics/ behaviour and common properties/
attributes. It is a user-defined blueprint or prototype from
which objects are created. For example, Student is a class
while a particular student named Ravi is an object.
11)what is object
Ans=object is a blueprint of class
Object is a super class of the all class.
If we create any class which is predefine all other the classes
in program are the sub classes of object class
So we can use object class reference variable to sub class
object
There are a method in object class
Hash code method=integer
To string method=return String to string method used to
represent object in string format.

13)what is super class all the classes in java.


Ans=object

14)what is override annotation


15)what is runtime exception and compile time exception
Runtime= =The runtime errors are the errors which are not generated
by the compiler and produce an unpredictable result at the execution
time.

Compile= The compile-time errors are the errors which are produced at
the compile-time, and they are detected by the compiler.

16)what is Collection

17)what is array
Arrays are used to store multiple values in a single
variable, instead of declaring separate variables for each
value.
To declare an array, define the variable type with square
brackets:

18) what is hash list


Ans= we cannot duplicate store in array list
We can store only one value in array list
19)array list
Ans=we can duplicate store in array list
We can store any null value in array list

18. What is a singleton class in Java? And How to implement


a singleton class?

A class that can possess only one object at a time is called a


singleton class. To implement a singleton class given steps
are to be followed:

1. Make sure that the class has only one object


2. Give global access to that object
19)Different between abstract class and interface class
Interface class Abstract class
1.interface contain only 1.abstract class contains both
abstract method abstract and non abstract method
2. in interface variable are 2.in abstract class static or non static
static and final only and final and no final variable are
3, we can’t create object of present
interface class 3. ,we can’t create object of abstract
class

20) what is exception in java


Ans=an wanted un expected event that occurs at runtime
which distance in normal flow of program is called exception.

21)what is servlet
Ans=servlet used in web application for backend prepose
Servlet based on java technology

23)what is static
Ans= static means if we want to use latest values multiple
times we create object variable not static then multiple
copes will be create .
But variable is static single copes will be create
Whenever if u want use the variable latest value .
Static we can use if we want call variable using class.
24)what is final variable.
Ans=if we don’t want change variable the we use final
variable.
If we don’t want override method then we use static variable.
If wen don’t want extend class then u use final variable .

25)protected access
Ans=protected we can use with a same package and other
package also provided we use inheritance .
j
26)what is garbage collection in java.
Ans=Garbage collection in Java is the process by which Java
programs perform automatic memory management. Java
programs compile to bytecode that can be run on a Java
Virtual Machine, or JVM for short.
27)what is array list…
Ans= array list is the class in java it present it java. Utile
package it have some inbuild method like add,addall,remove
By Using array list, we can add mean type of data add in array
list
In array list duplicate elements also allow.

28)Different between in this and super keyword


Ans= super and this both keyword in java
Super This
1)super keyword is 1)this keyword used
used to access to access the
immediate parent immediate class
class method variable constructor.
variable constructor.

29)default values
Ans=int= 0,float=0.0,Boolean =false, double=0.00,char=blank,
String=null.

30)what the final keyword.(not Sure)


Ans=final keyword in java declare as a constant. Once we
declare variable as final then we can’t change value of that
variable. If we declare method as a final we can override
method in subclass. If we

31) What is static blocks.


Ans= Static block is used to initialize the static data member.
It is executed before the main method, at the time of class
loading.
32) Multithreading in Java is a process of executing multiple
threads simultaneously.
Multiprocessing and multithreading, both are used to
achieve multitasking.
Java Multithreading is mostly used in games, animation, etc.
33) Collections in Java
The Collection in Java is a framework that provides an
architecture to store and manipulate the group of objects.
Java Collections can achieve all the operations that you
perform on a data such as searching, sorting, insertion,
manipulation, and deletion.
Java Collection means a single unit of objects. Java Collection
framework provides many interfaces (Set, List, Queue,
Deque) and classes (ArrayList,
Vector, LinkedList, PriorityQueue, HashSet, LinkedHashSet,
TreeSet).

34) What is the difference between JDK, JRE, and JVM?


JVM ----JVM is an acronym for Java Virtual Machine; it is an abstract machine
which provides the runtime environment in which Java bytecode can be
executed.

JVMs are available for many hardware and software platforms

JRE----JRE stands for Java Runtime Environment. It is the implementation of


JVM. The Java Runtime Environment is a set of software tools which are
used for developing Java applications. It is used to provide the runtime
environment. It is the implementation of JVM. It physically exists. It contains
a set of libraries + other files that JVM uses at runtime.

JDK----JDK is an acronym for Java Development Kit. It is a software development


environment which is used to develop Java applications and applets. It physically
exists. It contains JRE + development tools. JDK is an implementation of any one of
the below given Java Platforms released by Oracle Corporation:
Class loader-----

Class loader is a subsystem of JVM which is used to load class files. Whenever we run
the java program, it is loaded first by the classloade

35) What is the constructor?

The constructor can be defined as the special type of method


that is used to initialize the state of an object

The constructor must not have an explicit return type.

36) Why is Inheritance used in Java?

o Inheritance provides code reusability. The derived class does not need to
redefine the method of base class unless it needs to provide the specific
implementation of the method.
o Runtime polymorphism cannot be achieved without using inheritance.
o Runtime polymorphism cannot be achieved without using inheritance.

60) Why is multiple inheritance not supported in java?


To reduce the complexity and simplify the language, multiple inheritance is not
supported in java. Consider a scenario where A, B, and C are three classes. The C class
inherits A and B classes. If A and B classes have the same method and you call it from
child class object, there will be ambiguity to call the method of A or B class.

Since the compile-time errors are better than runtime errors, Java renders compile-
time error if you inherit 2 classes. So whether you have the same method or different,
there will be a compile time error.
1)different between overloading and overriding.
2)hash set difference between in hash set and array list
3)how read rest Api in java program .
4)what is multithreading.
5)different between array list and array.
6)different between global and local variable.

You might also like