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 void data type?
What is regex used for?
Name component subclasses that support painting in java programming?
Is string a data type in java?
What is the file type?
Is string a class in java?
Can I declare class as static or private?
What do you understand by private, protected and public?
What are the core java topics?
What are the main concepts of oops in java?
What are the 6 boolean operators?
Explain java coding standards for variables ?
What is a copy constructor in java?
Explain what do you mean by functional overloading in java?
How can the checkbox class be used to create a radio button?