Follow Our FB Page << CircleMedia.in >> for Daily Laughter. We Post Funny, Viral, Comedy Videos, Memes, Vines...


How can final class be used?

Answers were Sorted based on User's Feedback



How can final class be used?..

Answer / pranab dutta

A final class may not be subclassed so a final class can't
be extended. It means a final method can't be overridden
when its class is inherited. A final variable is a constant
which you can't change value of a final variable.

Is This Answer Correct ?    13 Yes 0 No

How can final class be used?..

Answer / user

One scenario where final is important, when you want to prevent inheritance of a class, for security reasons. This allows you to make sure that code you are running cannot be overridden by someone.

The best example is
public final class String

Is This Answer Correct ?    3 Yes 0 No

How can final class be used?..

Answer / chinmay

To prevent inheritance final class is used.

Is This Answer Correct ?    1 Yes 0 No

How can final class be used?..

Answer / jayant gope

Final is keyword that can be used with class, method and also with the variable.

Class: When final is used with the class, it means that class cannot be further extended or inherited by the other classes. So, final keyword restricts class from being inherited.

Method: When final is used with the method, this means that method cannot be overridden.

Variable: When final is used with the variable, it makes the variable constant i.e. the variable cannot be further modified.

Is This Answer Correct ?    1 Yes 0 No

How can final class be used?..

Answer / rajkumar ksr college

interface Used to declare a special type of class that only
contains abstract methods, constant ( static final ) fields
and static interfaces. It can later be implemented by
classes that declare the interface with the implements
keyword
http://en.wikipedia.org/wiki/Java_keywords
Class verifier from JDK 1.2 beta 4 also makes it impossible
for JavaGO to inline constructors and replace virtual calls
with non-virtual.JavaGO has special options -not-inline-
constructor and -not-use-invokespecial to disable such
optimizations.Option -not-inline-virtual prevents JavaGO
from inlining virtual methods (while it can still inline
final and static methods)and in conjunction with -not-use-
invokespecial option makesoptimization performed by JavaGO
really safe (such classes can be used with other classes
not presented to JavaGO), but looks like such
optimizationsalso can be done by Java compiler with -O
option.

Is This Answer Correct ?    2 Yes 2 No

Post New Answer



More Core Java Interview Questions

What is the purpose of using break in each case of switch statement?

0 Answers  


Difference between throw and throws?

0 Answers  


What is a hashmap used for?

0 Answers  


How many decimal places is a double?

0 Answers  


How to instantiate member inner class?

0 Answers  






How to declare an arraylist in java?

0 Answers  


explain oops concepts with examples?

29 Answers   AbhiBus, Beeline, DELL, HCL, Satyam, TCS, VLS, Wipro,


Can subclass overriding method declare an exception if parent class method doesn't throw an exception?

0 Answers  


What is the concept of multithreading?

0 Answers  


Explain break statement and continue statement?

3 Answers  


What is the difference between private & public & friendly classes?

0 Answers  


Explain covariant method overriding in java.

0 Answers  






Categories