Answer Posted / al rahid
1. Declare the Class as final (this inherently makes all
member function final)
2. Declare member variables private (not necessarily final,
because private instance variable are accessed via public
member functions only, e.g. in java.lang.String class,
variable "hash" is declared as "private int hash;" with no
final keyword).
| Is This Answer Correct ? | 2 Yes | 1 No |
Post New Answer View All Answers
Why singleton pattern is better than creating singleton class with static instance?
Can an interface extend a class?
If a method is declared as protected, where may the method be accessed?
How would you use Bubble Sort to sort the number of elements?
What is the difference between assignment and initialization?
How does callback work in java?
What is the difference between hashset and treeset in java?
Explain creating threads by implementing runnable class?
Can we use switch statement with strings?
What is a variable declaration?
What is abstract class? Explain
Can we modify the throws clause of the superclass method while overriding it in the subclass?
Can a class be private or protected in java?
What is the use of singleton?
What is primitive data type in java?