Wrapper Classes

17. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class M17 { public static void main(String[] args) { String s1 = "9.8"; float f1 = Float.parseFloat(s1); double d1 = Double.parseDouble(s1); System.out.println("------"); System.out.println(f1); System.out.println(d1); System.out.println("------"); int i = Integer.parseInt(s1); System.out.println("done"); } }

18. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class M18 { public static void main(String[] args) { String s1 = "abc"; String s2 = "true"; boolean b1 = Boolean.parseBoolean(s1); boolean b2 = Boolean.parseBoolean(s2); System.out.println(b1); System.out.println(b2); } }

19. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class M19 { public static void main(String[] args) { String s1 = "p"; //char c1 = Character.parseChar(s1); System.out.println("done"); } }

20. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

class M20 { public static void main(String[] args) { int i = 10; double j = i; System.out.println("done"); } }

21. Program

//Find what it gives Compiletion Error / Compiletion Successfully / Output ?

//file must save as M21 class A { } class B extends A { } public class M21 { public static void main(String[] args) { A a1 = new B(); Object o1 = new A(); Object o2 = new B(); System.out.println("done"); } }

Page....