Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


what is finalmethod & final variable with example?

Answers were Sorted based on User's Feedback



what is finalmethod & final variable with example?..

Answer / aditi

Final method cannot be overridden by subclasses. This is
used to prevent unexpected behavior from a subclass
altering a method.

Example:

public class MyClass {
public final void myFinalMethod() {...}

Final Variable, it can only be assigned to once and only in
the constructor of class if variable is not a reference to
pther object.

Example:

public class Sphere {

public static final double PI = 3.141592653589793; //
this might as well be a constant
public final double radius;
public final double xpos;
public final double ypos;
public final double zpos;

Sphere(double x, double y, double z, double r) {
radius = r;
xpos = x;
ypos = y;
zpos = z;
}

Is This Answer Correct ?    10 Yes 0 No

what is finalmethod & final variable with example?..

Answer / pavan

final method or variable is nothing but once if we declare
as it is final the value of that variable cant be changed
and becomes const.
Example:
--------
final b=200;
Here the value of b is 200 thought the prog
class A
{
void final b=200;
}//A
class B extends class A
{
this.b=201;//Error becoz the variable b is declared as final
//Here this represents the current value i.e.,in
class B that is about variable final

Know coming to the method:
-------------------------
final Add();//similar as variable
Final method can be def as the method name can not be
re-used and at the same time it cant be overridden..
Example:
--------
class A{
final Add()
{
int a,b,c;//Here in this we are adding two int no.
c=a+b;
}
class B extends class A
{
final Add()
{
float a,b,c;//Here we are adding two float no.
c=a+b;
}

Is This Answer Correct ?    0 Yes 0 No

what is finalmethod & final variable with example?..

Answer / vignesh,c

in a class if a method is executed at final stage is called
a final method, and and a variable when used finally is
called a final variable.

Is This Answer Correct ?    0 Yes 1 No

what is finalmethod & final variable with example?..

Answer / vignesh,c

in a class if a method is executed at final stage is called
a final method, and and a variable when used finally is
called a final variable.

Is This Answer Correct ?    0 Yes 2 No

what is finalmethod & final variable with example?..

Answer / vignesh,c

in a class if a method is executed at final stage is called
a final method, and and a variable when used finally is
called a final variable.

Is This Answer Correct ?    0 Yes 3 No

what is finalmethod & final variable with example?..

Answer / dipesh

public final methodA(){

}
u can overirde final method & final variable can reassigned
another value & final varaiable value must be assingend at
the time of declaration

Is This Answer Correct ?    2 Yes 11 No

Post New Answer

More Core Java Interview Questions

What is the buffer limit?

0 Answers  


Can you sort a list in java?

0 Answers  


What is google full form?

0 Answers  


Can a boolean be null java?

0 Answers  


How will you calculate the depth of a binary tree if the tree contains 15 nodes?

0 Answers   Aricent,


Explain the difference between abstract classes and interfaces in java?

0 Answers  


Explain abstract class in java?

0 Answers  


What is an interface in java?

0 Answers  


Name few "optional" classes introduced with java 8 ?

0 Answers  


What are the elements of java?

0 Answers  


What are wrapper classes in java?

0 Answers  


difference between arraylist and linkedlist otherthan performance

2 Answers   L&T,


Categories