Java Data Types and their default values

In this tutorial, you will learn about java Data Types and their default Values.

You will learn what are the data types available in java, what default values they get when variables are created, how to check for the default values in detail with example.

Source code for this video tutorial

Code for Student.java

package oops;

public class Student {
 String name;
 int rollno;
 char sex;
 boolean hasgf;
 
 void display(){
  System.out.println("name is "+name);
  System.out.println("rollno is "+rollno);
  System.out.println("sex is "+sex);
  System.out.println("has Girl Friend is "+hasgf);
 }
 
 void displayAgain(){
  String fname;
  int num;
  
  System.out.println(fname+num);
 }
}

Code for Tutorial.java

package oops;

public class Tutorial {

 public static void main(String[] args) {
  
  Student anil = new Student();
  anil.display();
 }
}
Back To Top