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.
class Rectangle { private double l, b; Rectangle(double l, double b) { this.l = l; this.b = b; } double area() { return l * b; } }
No citable source has been recorded for this record. Treat it as practice material, not as fact.
The this keyword distinguishes the fields from the parameters of the same name.
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
What is constructor overloading? Give one situation in which it is useful.
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