Write a default constructor in the user exception class in java
Answers
Answered by
2
public class Tester {
int a;
String b;
public static void main(String[] args) {
//Default constructor
//is called to create a new object
Tester t = new Tester();
//print the default values
System.out.println(t.a);
System.out.println(t.b);
}
}
Output
0
null
Explanation:
Java compiler automatically creates a default constructor (Constructor with no arguments) in case no constructor is present in the java class. Following are the motive behind a default constructor.
Create the Object
Call the super class constructor()
Initialize all the instance variables of the class object
Answered by
2
Explanation:
hope this helpful to u dear, ......
Attachments:
Similar questions