Java Data Types and their default values

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

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 Source Code for Student.java

 1 package oops;
 2 
 3 public class Student {
 4     String name;
 5     int rollno;
 6     char sex;
 7     boolean hasgf;
 8     
 9     void display(){
10         System.out.println("name is "+name);
11         System.out.println("rollno is "+rollno);
12         System.out.println("sex is "+sex);
13         System.out.println("has Girl Friend is "+hasgf);
14     }
15     
16     void displayAgain(){
17         String fname;
18         int num;        
19         System.out.println(fname+num);
20     }
21 }


Source Code for Source Code for Tutorial.java

1 package oops;
2 
3 public class Tutorial {
4     public static void main(String[] args) {        
5         Student anil = new Student();
6         anil.display();        
7     }
8 }

Watch this video to learn how this works