This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Which of the following are true about the "default" constructor? Select 2 correct options (1) It is provided by the compiler only if the class does not define any constructor (2) It initializes the instance members of the class (3) It calls the default 'no-args' constructor of the super class (4) It initializes instance as well as class fields of the class (5) It is provided by the compiler if the class does not define a 'no- args' constructor
An anonymous inner class doesnt have a constructor...only instance initializer
Yes it does - only you can't define any.
Consider this case:
There is a constructor, that takes a String. There are even constructors that take an Icon, or a String and an Icon, or any other constructor AbstractAction has. As for anonymous classes implementing interfaces (new ActionListener() ...), there is also a constructor - a non-arg constructor.
(2) It initializes the instance members of the class ... my doubt is why not 2 is correct .....
Seems two books I checked agree with you: From Core Java (J2SE 5.0) , Volume I, Page 128
If you write a class with no constructors whatsoever, then a default constructor is provided for you. This default constructor sets all the instance fields to their default values. So, all numeric data contained in the instance fields would be 0, all Booleans would be false, and all object variables would be set to null.
From K&B 1.4. Page 314 when they discuss constructor chaining they also say:
5. Object constructor completes 6. Animal instance variables are given their explicit values (if any) 7. Animal constructor completes
Where did you get the question from? Do they provide any answer?
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com