// Primitive Type Casting Order -- byte < short < int < long < float < double //
11. Program
//Find the O/P ? Compile Time Error or Compile Successfully
class K
{
public static void main(String[] args)
{
byte i = 100;
double j = (double)i;
System.out.println("Done");
}
}
12. Program
//Find the O/P ? Compile Time Error or Compile Successfully
class M
{
public static void main(String[] args)
{
byte b = 100;
int i = b;
int j = (int)b;
double d = i;
double d1 = (double)i;
System.out.println("Done");
}
}
13. Program
//Find the O/P ? Compile Time Error or Compile Successfully
class N
{
static void test(double d)
{
System.out.println("from test(double)");
}
public static void main(String[] args)
{
int i = 10;
test(i);
System.out.println("Done");
test((double)i);
System.out.println("Done");
}
}
14. Program
//Find the O/P ? Compile Time Error or Compile Successfully
class O
{
static int test1()
{
byte b = 10;
return b;
}
static int test2()
{
byte b = 10;
return (int)b;
}
public static void main(String[] args)
{
double d1 = test1();
double d2 = (double)test2();
System.out.println("Done");
}
}
15. Program
//Find the O/P ? Compile Time Error or Compile Successfully
class P
{
public static void main(String[] args)
{
double d1 = 10.9;
int i = d1;
System.out.println("Done");
}
}
16. Program
//Find the O/P ? Compile Time Error or Compile Successfully
class Q
{
public static void main(String[] args)
{
double d = 20.7;
int i = (int)d;
System.out.println(d);
System.out.println(i);
}
}