Type Casting

// Primitive Type Casting Order -- byte < short < int < long < float < double //


1. Program

//Find the O/P ? Compile Time Error or Compile Successfully

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

2. Program

//Find the O/P ? Compile Time Error or Compile Successfully

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

3. Program

//Find the O/P ? Compile Time Error or Compile Successfully

class C { public static void main(String[] args) { short i = 20; double j = i; System.out.println("C"); } }

4. Program

//Find the O/P ? Compile Time Error or Compile Successfully

class D { public static void main(String[] args) { int i = 20; float j = i; System.out.println("D"); } }

5. Program

//Find the O/P ? Compile Time Error or Compile Successfully

class E { static void test(double d) { System.out.println("test(double)"); } public static void main(String[] args) { int i = 20; test(i); System.out.println("Done"); } }

Page....