Although i understood the main concept behind this question - that flipper method is final but private in Clidder.So we can have same method in Clidlet also.
But i never came across something like:
The only time i know that we can use a class name to call a method is, when the method is static.So my question is
what does Clidlet().flipper do?
Of course by looking at it, it seems that it is calling flipper method from class Clidlet.
But why this syntax- Clidlet()
Here is the program:
What is the result?
The answer given in the book is option A which is as expected.But i don't understand the syntax.
And also Anytime i use an object , i use following syntax:
classname refvariable = new classname();
But in above program:
So how is this done?
The new operator returns a reference to the object it created. This reference is usually assigned to a variable of the appropriate type, like:
Point originOne = new Point(23, 94);
The reference returned by the new operator does not have to be assigned to a variable. It can also be used directly in an expression. For example:
int height = new Rectangle().height;