Basic Programs Of Java

8. Program

//Find the O/P ?

class H { public static void main(String args[]) { int i, j, k = 10, m; i = 20; j = i + 30; m = j + k + 20; System.out.println(i); System.out.println(j); System.out.println(k); System.out.println(m); } }

9. Program

//Find the O/P ?

class I { public static void main(String args[]) { int x = 10; int x = 20; // Same Variable Can't Declear System.out.println(x); } }

10. Program

//Find the O/P ?

class J { public static void main(String args[]) { int x = 10; x = 20; //Reinitialization System.out.print(x); } }

11. Program

//Find the O/P ?

class K { public static void main(String args[]) { int i, j, m; double n; i = j = m = 10; n = 30.95; System.out.println(i); System.out.println(j); System.out.println(m); System.out.println(n); } }

12. Program

//Find the O/P ?

class L { public static void main(String args[]) { int i, j; double m, n = 10.9, p; i = 10; j = 40; m = 1.2; p = 3.6; System.out.println(i); System.out.println(j); System.out.println(m); System.out.println(n); } }

13. Program

//Find the O/P ?

class M { public static void main(String args[]) { System.out.println(i); // Compile Time Error int i = 10; } }

14. Program

//Find the O/P ?

class N { public static void main(String args[]) { int i; //local variable must be initialized Before Usage System.out.println(i); } }

Page....