what is the difference b/w static and final methods?



what is the difference b/w static and final methods?..

Answer / guest

There is lot of difference b/w static and final Method....

Static Method.....

1). Static Method is part of class object. all static method
is loading after class is loading into the Memory(i.e heap).
2). All static Method can be access by Either class Name or
instance of the class.
3). While static method accessing by instance of the class
compiler is internally it converting into it's class reference.
4). Static methods can't be override.
5). By static Method we can't achieve Dynamic Method
dispating functionally.
6). static method is part of class object only.
7). Static method can't be call the non-static method
directly(i.e without creating instance of the class)
8). But Non static method can call the static methods.bcz of
static method are universal method these can be access by
any where either by class Name or by intance of the class.

Final Methods....

1). Final method are followed by final keyword.
2). Final method can't be inherited in subclass.
3). Final method can't be override in subclass also.
4). Final methods are faster than non-final methods because
they are not required to be resolved during run-time and
they are bonded on compile time.

For example

class PersonalLoan{
public final String getName(){
return "personal loan";
}
}
class CheapPersonalLoan extends PersonalLoan{
@Override
public final String getName(){
return "cheap personal loan"; //compilation error:
overridden method is final
}
}

Is This Answer Correct ?    9 Yes 0 No

Post New Answer

More Core Java Interview Questions

When you declare a method as abstract method ?

2 Answers   HP,


how to make hashmap object as synchronized object?

2 Answers   BOB Technologies,


What is Restrictions in hibernate?

1 Answers   Bally Technologies,


How thread scheduler schedule the task?

0 Answers  


What are the access modifiers in java?

0 Answers  






Can a class be declared as static?

0 Answers  


What is the purpose of interface?

0 Answers  


What are the different types of data structures in java?

0 Answers  


Given: 1. package test; 2. 3. class Target { 4. public String name = “hello”; 5. } What can directly access and change the value of the variable name? 1 any class 2 only the Target class 3 any class in the test package 4 any class that extends Target

7 Answers   Infosys, WW,


How many inner classes can a class have?

0 Answers  


Which class should you use to obtain design information about an object

2 Answers  


What is constructor

9 Answers   Manforce, Tech Mahindra,


Categories