Answer Posted / venu gopala reddy
a better approach. Make the immutable class itself final. Hence cannot make any sub classes, so no question of over ridding.
write code for user immutable class:-
final class ImmutableVenu{
private final int count;
private String phno="9742108000";
public ImmutableVenu(int paramCount,String paramPhno){
count=paramCount;
phno=paramPhno;
}
public int getCount(){
return count;
}
public String getString(){
return paramPhno;
}
}
public static void main(String ar[])
{
ImmutableVenu immu=new ImmutabeVenu();
s.o.p(immu.getCount());
s.o.p(immu.getPhno());
}
Is This Answer Correct ? | 1 Yes | 1 No |
Post New Answer View All Answers
What is the properties class in java programming?
What is length in java?
EDS (Electronic Data Systems India Pvt Ltd) at Chennai on 16-12-2006.
How does sublist works in java?
Difference between association, composition and aggregation?
What does this mean java?
Does java support function overloading, pointers, structures, unions or linked lists?
What are the main features of java?
Is java owned by oracle?
What are memory tables?
what is meant by Byte code concept in Java?
Is it possible to write a regular expression to check if string is a number?
If an object reference is set to null, will the garbage collector immediately free the memory held by that object?
Can you pass functions in java?
Why do you canvas?