what is the use of declaring constructor as private?
Answer Posted / ranganathkini
By making all the constructors of a class private, you can
also prevent other class from extending the class without
marking the class final.
Is This Answer Correct ? | 9 Yes | 6 No |
Post New Answer View All Answers
what is singleton class in java?
Draw a UML class diagram for the code fragment given below: public class StringApplet extends Applet { private Label sampleString; private Button showTheString; private ButtonHandler bHandler; private FlowLayout layout; public StringApplet() { sampleString = new Label(" "); showTheString = new Button (" Show the String"); bHandler = new ButtonHandler(); layout = new FlowLayout(); showTheString.addActionListener(bHandler); setLayout(layout); add(sampleString); add(showTheString); } class ButtonHandler implements ActionListener { public void actionPerformed(ActionEvent e) { samplestring.setText("Good Morning"); } } } Note: The methods need not be indicated on the diagram.
What is the unit of plancks constant?
How do you sort a string in java?
Why singleton pattern is better than creating singleton class with static instance?
How the metacharacters are different from the ordinary characters?
What are the object and class classes used for?
Can a singleton class be inherited?
What is arrays fill in java?
Can you add null to a list java?
How many types of methods are there in java?
Why are arrays useful in java?
How do you add an element to a set in java?
What is extension method in java?
Justify your answer that you can't define a method inside another method in java, if you can then how?