Java Default Attributes

Java Default Attributes


Default Attribute In Java
 
The default attribute is nothing but the attributes with no access modifiers set to them.
Default also means no modifier specified 
A default can be a class a method or an attribute etc 
We can understand default attributes with the help of the examples we have used above.
 
Example - 
 
import second.*;
import java.util.*;

class T{
  static String str = "Hello world";
}

class Main {

  public static void main(String[] args) {
// TRYING TO ACCESS SecondClass without making it public
// hence trying to access a default class from another package
      // accessing default data in same clsss.
      int a = 90;
      int b = 10;
      System.out.println("the sum of a and b is = "+ (a+b));
      // accessing another class data in Manin calss with same package.
          System.out.println(T.str);

          }
  }

 
 
Output - 
 
 
Example 2 - 
 

 
Example-
 
 
Output -