how is Title.HORROR prints HORROR in output.shouldn't a variable of type Title be made in public static void main(String arg[]) and then after assigning value it should be accessed
-----------------------------------------------
Problem-2
here enum is declared to be member of class deleteme
a)how can enum instance variable myDog be declared in main method of deleteme without object of deletme class ??
b)shouldn't it be done in the way as done with var of cats in class deleteme ??
c) cats myDog = cats.tom;
can i access myDog with class deleteme i.e.
a.myDog
a)how can enum instance variable myDog be declared in main method of deleteme without object of deletme class ??
Ans..because enum declared within a class are implicitly static,so it is perfectly fine
b)shouldn't it be done in the way as done with var of cats in class deleteme ??
Ans..or you can try it.
c) cats myDog = cats.tom;
can i access myDog with class deleteme i.e. a.myDog
Ans.. No sticly no...
the objects of enum are static and final(not the objects but basicallly the refernce variable are static variable)...myDog is a refernce variable which is already been assigned to cats.tom (i.e tom) which is final.
and i have not seen two refernce variable like this.a.myDOg(where "a" refernce variable for deleteme and "myDog" is final reference variable for cats which will always be point to "tom")
how is Title.HORROR prints HORROR in output.shouldn't a variable of type Title be made in public static void main(String arg[]) and then after assigning value it should be accessed..