1. Program 1
class Program
{
public static void main(String [] args)
{
for(int i=0; 1 ;i++)
{
System.out.println("ProgrammingInfinitum");
}
}
}
Output: Compiler Error
In for loop there is an error in condition check.
2. Program 2
class Program
{
public static void main(String[] args)
{
System.out.println('A'+'B');
}
}
Output: 131
A and B are characters here, hence their unicodes will add(A = 65 and B = 66).
3. program 3
package packOutputJava;
public class OutputJava {
public static void main(String [] args)
{
System.out.println(21+21.3f+"A"+'B');
}
}
class Program
{
public static void main(String [] args)
{
for(int i=0; 1 ;i++)
{
System.out.println("ProgrammingInfinitum");
}
}
}
Output: Compiler Error
In for loop there is an error in condition check.
2. Program 2
class Program
{
public static void main(String[] args)
{
System.out.println('A'+'B');
}
}
Output: 131
A and B are characters here, hence their unicodes will add(A = 65 and B = 66).
3. program 3
package packOutputJava;
public class OutputJava {
public static void main(String [] args)
{
System.out.println(21+21.3f+"A"+'B');
}
}
Output: 42.3AB
int and float value adds to give 42.3 and A (String) and B (character) concatenates with it.
No comments:
Post a Comment