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

Java_Interview_Series_Part_4__1677674916

Uploaded by

67mimi67
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

Java_Interview_Series_Part_4__1677674916

Uploaded by

67mimi67
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

Java Interview Series

Java INTERVIEW
( PART- 4 )

Developer_pani
Hi Preethi..! I am Pani.
Hey Pani ! Thanks
I am going to take
for giving me this
your technical round.
oppportunity.
I am going to ask
few Java Questions.
okay,
pani.
In Java, the final keyword is
used as defining something
as constant /final and
Explain the use of represents the non-access
final keyword. modifier.
ok... what is the use of
final keyword in
variable, method and final variable...
class
Final variable :

When a variable is declared as final in Java,


the value can’t be modified once it has been
assigned.

If any value has not been assigned to that


variable, then it can be assigned only by the
constructor of the class.

Syntax:
final int number = 10;
Final Method:
A method declared as final cannot be
overridden by its children's classes.

A constructor cannot be marked as final


because whenever a class is inherited, the
constructors are not inherited. Hence,
marking it final doesn't make sense. Java
throws compilation error saying-
modifier final not allowed here

final class:
No classes can be inherited from the
class declared as final. But that final class
can extend other classes for its usage.
Final Method example:

Final Class example:


Simply, we can say

To be continued in
next part...
Developer_pani

Join the telegram channel te get the notes,


Interview Q & A and other resources

( Link in Bio )

You might also like