Answer Posted / khizar khan
1) Make a class fianl like final class A{}
2) Then use the property as private and final
ex:
final class A{
private final int salary;
}
3)Now make a Constructor to initilize the values
ex:
A(int a)
{ this .salary=a;
}
4)Now use the gtter mathod to acces the values
ex:
final class A{
private final int salary ;
A( int a)
{
this.salary=a;
}
public int getSalary()
{
return salary;
}
}
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
Can we clone singleton object in java?
What is scope & storage allocation of global and extern variables? Explain with an example
What is volatile keyword in java
What is collection api?
what r advatages of websphere? & how to deploy?
What is java in layman terms?
What is a boolean structure?
When is finally block not called?
How do you calculate square roots?
can I implement my own start() method? : Java thread
Difference between arraylist and hashset in java?
Can you give few examples of final classes defined in java api?
What do you understand by the term singleton?
What is the original name of java?
What is a constructor overloading in java?