Volatile Variable: Whenever a variable is declared as volatile, the thread accessing the variable have to reconcile its copy of variable with the master copy of that variable....Transient:We can decla...
Transient: The transient modifier applies to variables only and it is not stored as part of its object's Persistent state. These variables are not serialized. Transient instance fields are neither sav...
Some people might get confused by the many posts. The correct answer to the question "can we declare class as protected?" is YES, BUT only as an inner class. A 'normal' class cannot be protected or private.
// 'Normal' class - only default or public allowed
public class ProtectedOrNot {
// Inner class - public, default, protected, private allowed
protected class InnerClass {
}
public static void main(String[] args) {
}
}
vishal
Sep 21st, 2017
We cannot declare primary classes as protected for primary classes only "public","final","abstract" are allowed.
But point to be noted you can declare inner classes as protected.
...
Srinu
Jul 8th, 2017
We cannot declare class as protected and private it gives compile time error.
Illegal modifier for the class TestClass; only public, abstract & final are permitted
Pankaj Vishwani.....your code is compiling because you have prefixed the kerword void before the constructor of stud class...... hence its not a constructor anymore.... its beheaving like a method as ...
Ram
Jan 8th, 2007
Well pankaj. The deal is to make the constructor private. In your example you have created a method as private as constructor do not have any return type. So try compiling again. cheers. Ram