




























































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!





























































































// Java Program to demonstrate use of default values import java.io.; class GFG {* // static values static byte b; static int i; static long l; static short s; static boolean bool; static char c; static String str; static Object object; static float f; static double d; static int[] Arr; public static void main(String[] args) { // byte value System.out.println("byte value" + b); // short value System.out.println("short value" + s); // int value System.out.println("int value" + i); // long value System.out.println("long value" + l); System.out.println("boolean value" + bool); System.out.println("char value" + c); System.out.println("float value" + f); System.out.println("double value" + d); System.out.println("string value" + str); System.out.println("object value" + object); System.out.println("Array value" + Arr); } }
+ GFG.ctr); } }
// Java Program to demonstrate Instance Variable import java.io.; class GFG { private String name; public void setName(String name) { this.name = name; } public String getName() { return name; } public static void main(String[] args) { GFG obj = new GFG(); obj.setName("John"); System.out.println("Name " + obj.getName()); }*
// Java Program to demonstrate Class Variable import java.io.; class GFG {* // class variable **private static final double PI = 3.14159; private double radius; public GFG(double radius) { this.radius = radius; } public double getArea() { return PI * radius * radius; } public static void main(String[] args) { GFG obj = new GFG(5.0); System.out.println("Area of circle: "