java. 2
java. 2
4;?, Java4Quicklearning
Q. What do you understand by OOPs in java?
OOPs is abbreviated as Object Oriented Programming
system in which programs are considered as a collection
of objects. Each objectis nothing but an instanceof a
class.
• OOPs has four pillars -
i) Inheritance
ii) Polymorphism
iii) Abstraction
iv) Encapsulation
Q. Why do we use object-oriented programming?
• OOPs make the development and maintenance of
projects easier.
• OOPs provide the feature of data hiding that is good for
security concern. '"'
• We can provide the solution to real-world problems if we
are using object-oriented programming.
«
•~J
-=- icklearning
Java
,.
fl Original sound
Java
Vo ~ r.;-:;,
34
10:26AM .11 WiFi ':" ~•
"~ Java4Quicklearning
Java
Q. What is encapsulation in java?
Encapsulation in Java is a process of grouping data
members and corresponding methods into a single unit.
I°"
E t'\C:.°'-pS.c..c ti C>t'\
IN - CAP.SULE - a-.t,o"'
En
._~ ,
--=- ·cklearning
Javd
Rem1
ai 1ew e
fl Original sound
,_ 6 (±) 0
-
e~c.~psul~tio""
IN - CAf=>.SULE - CAt,ot'\
·ckLearning
. (
10:28 AM ... ~~F, ~ QD,
f- Q :
,i f Java4Quicklearning
Java
Q. What is polymorphism injava?
Polymorphism in Java is a concept by which we can
perform a single action in different ways. Polymorphism is
derived from 2 Greek words: poly and morphs.
The word "poly" means many and "morphs" means forms .
So polymorphism means many forms.
'Types of Polymorphism
complle time
polymorphism
run-time
polymorphism m
I
(static or early binding) (dynamic or late blndln~b
·cklearning
{
~ org
riginal sound
Shorts
"!J: Java4Quicklearning
Java-
Q. What do you understand by Compile-time Polymorphism?
Compile-time polymorphism, also known as static
polymorphism, is a type of polymorphism that occurs
during the compilation process. It can be achieved by
Method Overloading.
lfil1l1!.l:-
lmliitb
~
Java-
Java4Quicklearning
Q. What do you understand by run-time
Polymorphism?
Dynamic polymorphism is another name for
runtime polymorphism.
In Java, method overriding is a technique for
implementing runtime polymorphism. It is also
sometimes known as Dynamic method dispatch.
Q. What is Method Overriding?
Method Overriding is a procedure in which the
compiler can allow a child class to implement a
specific method already provided in the parent
class. ,,
«
:_~ I
)dVd
mmm~
Original sound
Home Shorts
earning
QuickL
Java4
_J_{avka- Jav a ? m en ta tion
strac tion in g th e imple r. It
t is Ab o f hid in the us e
Q. Wha rocess
is a p ality to
ction
io n f u n
c t
Abstra d showing o nly
ing things.
tails a n xity o f view
de c ompl e
s the
reduce
ction
Abstra
e
Interfacction
bstra
100% a
bstract class
A abstrac
tion
0%
0 to 10
~ ,~
CR ERab ra
va l
<..j;
Java
~ Java4Quicklearning
Q. What is Abstract class in Java?
A class which is declared as abstract is known as an abstract
class.
Example - abstract class Java4Quicklearning {
//Non-abstract method
public void show() {
System.out . println("Hello World");
}
II Abstract method
abstract int getAdmissionFee();
}
Points to Remember
• An abstract class must be declared with an abstract keyword.
• It can have abstract and non-abstract methods. q,
• It can have constructors and static methods also.
• It can have flna
lm:ill~
(!)
«
•= )
..::::::.. earning
Java
' (
"~ ~ J a v a 4 Q u ic k le a r n in g
J ava
Q. What is the super keywor
d in Java?
pe r ke yw ord is us ed to invo ke the
The su
n m etho d, w hich ov er rides one o f its
overridde
superclass methods .
overridden
This keyword allows to access
et ho ds an d also to ac cess hi dden members
m
o f the superclass.
fo rw ar ds a ca ll fr om a co nstructor, to a
It also
constructor in t
ll
,r-1,:.
d
•~ J
'= -=
}dV d
~-=- :,- J a v a 4 Q u ., c k le a r n in g
--
Java
ist in Java?
Q . W h at is th e arrayl im plementation of the
is a re si za bl e ar ra y
A n A rr a yl is t in Ja va rt o f th e Ja va C ollections Framework.
is pa
Li st in te rf ac e, w hi ch
S yn ta x -
r> lis t = ne w A rr ay lis t< ln te ge r> ();
A rr ay lis t< ln te ge
ca n dy na m ic al ly gr ow and shrink in size.
is t
U nl ik e ar ra ys , A rr a yl ip ul at e th e si ze o f th e array th at is
to m an
It pr ov id es m et ho ds
or e th e lis t.
us ed in te rn al ly to st
E xa m pf e - th e en d o f lis t
ad d( 21 ); // ap pe nd to
ad d( 74 ); .
ad d( 92 ); fr om th e sp ec ifi c index
e( 2) ; // re m ov e
re m ov
<4~Java4Quicklearning
Java-
Q. What is the difference between an abstract class
and an interface?
• An abstract class can have both abstract and
non-abstract methods, while an interface can only
have abstract methods.
• Abstract class doesn't support multiple inheritance
but Interface supports multiple inheritance.
• The abstract keyword is used to declare abstract
class, while interface declare with the keyword
interface.
• An abstract class can be extended using keywor J 1
'
Ja va
g
Q. Wh at is the significance of th e
sta tic ke yw or d in
Java?
• The static keyword in Java is used
fo r me mo ry
management mainly.
• We can apply sta tic keyword wi th
variables,
methods, blocks and nested cla ss
es .
• These members are as so cia ted
wi th the cla ss
rather than wi th instances of the cla
ss .
Example -
st at ic ke yw or d us ag e
1. sta tic variables
static mt cou nt;
2. sta tic me tho ds
c;.t::itir vni rl fnn (\ n
~
._,
..:;;,...
)dVd
a 0
facebook
Threads
se t 1s soun
Hom e Shorts
.4~Java4Quicklearning
Java
Q. What are Literals in Java?
Literals have a consta nt value and a fixed data type
and are often known as consta nts in Java. Literals
are assigned to a variable to provide a value to the
variable.
Example -
Int num = 30
Types Of Literals
Chara cter literals -> 'a', 'A', 'N', 'q', etc ...
a YouTube
(@
q~
0
facebook
.
[¢] C)
Threads Ttltgtlffl "~
~~
- ., :..,
~ -- -
•• t-:
:..
fl Original sound
"Java-
{i;! Java4Quicklearning
Q. What is exception handling in java?
An exception is an event that occurs during the
execution of a program. Exceptions can be of any
type - Runtime exception, Error exceptions.
Due to this interrupts the normal flow of program
and rest of the code will not executed, to avoid this
unexpected interruption, these exceptions are
adequately handled through exception handling
mechanism like try, catch and throw keywords.
Example-
public class ExcepDemo {
System.out.println(ilj);
}
IAs the program throws
ArithmeticException, that
catch(ArithmeticException ae) {
mentioned inside catch
block
System.out.println("wrong
input");
D (@) 6 ~ 0 ~
YouTube q~ facebook Threads Ttl,gram
"'~
.......
0 ' ·-
-
:
- ,... - - ~ -~J w
fl Original sound
<-c.d;_ Java4Quicklearnin1
Ja va
Q. What is variables injava?
A Variable is a name given to a m
em or y location. 11
is used to store a value th at m ay
vary. Ja va is a
sta tic all y typed language, and he
nce, all th e
variables are declared be fo re use.
Example - ~
~ 0
0
int age= 21 ;
B
Types of Va ria ble s in Java
Local
[ ] Class
:
:,
'd Sab·.::.:r L~C.- & Fo llo w Us ~It ]{:.
=
1.1Tube
1~
®] 0
facebook
[€]
Threads
0 l.f] \1R~11'1:.P
~~ Java4Qu1. cklearning
'" '
< __ P a rt - # 1
Java return type String class
access modifier
! !
lic static void main ( String args[] )
pub
t i i
method name array ofstring objects
keyword
rn ty p e o f th e main() method?
Q. W h a t is th e re tu m e th o d in ja va is void'! '
th e m a in
T h e re tu rn ty p e o f in m e th o d d oesn't return any
e m a
T h is m e a n s th a t th th e void keyword .
is d e c la re d w it h
v a lu e . It
m.·m:<~
() m e th o d dec lared static?
Q. W h y is th e main ca lle d w it h o u t creating an
th o d to b e
It a ll o w s th e m e ic h it is defined .
c la s s in w h
in s ta n c e o f th e
Us
s ~t b·.::: r i ':,c• & Fo llo w
Ir
Javd
0 ~ ,_
C ) ~
a YouTul>e 1~
@J focebook
.-
"'~
Th rea ds
«)
- '"= ""
fl O ri gi na l so un d
Java Part - #2
access modifier return type String class
l
public static void main ( String args[] )
t
keyword
t
method name
t
array of string objects
'
A k le a r n in g
"J"a=va: J a v a 4 Q u ic Pa rt -# 3
access modifier retu rn type String class
J ! !
args[] )
public static void main ( String
t i t
keyword method name array orstring objects
: . j,
~
fl Original sound
Vo ~ '321
10:37AM .11 I WiFi ~ ~•
--~ Java4Quicklearning
Java
Q. What is Spring Framework?
fill
(I
klearning
01... J~
Remix
w java #SP-ring
ramewolil< ijavaAguicklearning
fl Original sound
DYouTube
0
facebook
~ ()
Threads TolOfl"'m
fl Original sound
"4~Java4Quicklearning
Java
Q. What is the difference between equals() and
equalslgnoreCase() method of String in java?
The equals() method compares two strings, and returns
true if the strings are equal, and false if not. it is a case
sensitive.
Example - String str1 = "Java4Quicklearning";
String str2 = "java4quicklearning";
boolean check= str1 .equals(str2);
Output : false
While The equalslgnoreCase() method compares two
strings, ignoring lower case and upper case differences.
(1)
1cklearning
~
Java
Java4Quicklearning
Core Java Interview Question
Q. What is Lamda Expression in Java?
Lambda expressions are the method without name
that is called Anonymous method.
Lambda expression is a function that can be passed
around and referenced as an object.
Lambda Syntax
• No arguments: () - > System.out.println("Hello")
a 0 ~
°! hrt:a:13
CD ii
,..._, WhatsApp
fl Original sound
Home Shorts
10:39 AM" • ,I I VWoF_
I I
~
• U
'3211
L..::?=...J
,4 Java4Quicklearning
Java
Q. Explain default method of interface in java.
Java 8 introduced the concept of default
methods.
Default methods are methods that can have a
body so implementing class no need to
implement.
Default methods in interfaces is to provide
additional functionality to a given type without
breaking down the implementing classes.
Example -
public interface Vehicle { 1..k
void cleanVehicle():
default void startVehicle(){
System.out.println("vehicle is startit 'L }
}
.:iit:1( :.
._~ ,
---
)dVd
Subscribe & Follow Us
a (®) 0 ~ C) 11
·,cu-:-. t. 1Jt~11'.!fl!'.U fo!:~~, ·:-.v~
·-- WhatsApp
Ja Original sound
Home Shorts
{I
< ?
Jav a
Ja va 4Q uic kle arn ing
Q. Wha t are wrap per classes in java?
• The wrapper class in Java provides the
mec han ism to convert primitive into object
and obje ct into primitive.
a "(ouTuhe
0 Ttloptom
fl Original sound