xxxxxxxxxx
class Main {
int a;
boolean b;
byte c;
short d;
long e;
char f;
float g;
public static void main(String[] args) {
// A default constructor is called
Main obj = new Main();
System.out.println("Default Value:");
System.out.println("int = " + obj.a);
System.out.println("boolean = " + obj.b);
System.out.println("byte = " + obj.c);
System.out.println("short = " + obj.d);
System.out.println("long = " + obj.e);
System.out.println("char = " + obj.f);
System.out.println("float = " + obj.g);
}
}
xxxxxxxxxx
public class Student {
String firstName;
String lastName;
int age;
//Student constructor
public Student(){
firstName = "Ihechikara";
lastName = "Abba";
age = 100;
}
public static void main(String args[]) {
Student myStudent = new Student();
System.out.println(myStudent.age);
// 100
}
}