Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVA

Default Constructor

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);
  }
}
Source by softhunt.net #
 
PREVIOUS NEXT
Tagged: #Default #Constructor
ADD COMMENT
Topic
Name
1+1 =