Distinguish between a default constructor and a parameterised constructor, and state what a copy constructor does.
Constructors
Original Khojo Papers practice question — not from a past board paper.
Constructor overloading is defining more than one constructor in a class, differing in the number, type or order of their parameters. It is useful when an object may be created with different amounts of information: a Rectangle might be created from a length and a breadth, from a single side for a square, or with no argument at all for default dimensions.
No citable source has been recorded for this record. Treat it as practice material, not as fact.
The compiler chooses the constructor that matches the argument list.
From the same topic and chapter, at a similar level.
Distinguish between a default constructor and a parameterised constructor, and state what a copy constructor does.
Constructors
Write a class Rectangle with a parameterised constructor and a method to return its area.
Constructors
State three differences between a constructor and a method.
Constructors
What is a constructor? State three of its characteristics.
Constructors
Explain the ternary operator in Java and rewrite "if (a > b) max = a; else max = b;" using it.
Operators and Expressions in Java
What is the output of: String s = "Examination"; System.out.println(s.length() + " " + s.substring(0, 4) + " " + s.toUpperCase().charAt(2));
String Handling