What is the output of this program ?

What is the output of this program ?

class Literal2 { public static void main(String[] args) { int i=0786; System.out.println(i); } } /* Output:- CE[Integer number too large]...

Read more »

What is the output of this program?

What is the output of this program?

class Literal1 { public static void main(String[] args) { int i=012; System.out.println(i); } } /* Output:- 10 Explanation:- A decimal...

Read more »

What is the output of this program?

What is the output of this program?

class DataType6 { public static void main(String[] args) { float f=5.5; System.out.println(f); } } /* Output:- CE[possible loss of precision]...

Read more »

What will be output if we pass "10 20" as command line argument?

class CommandLineArg3
{
static public void main(String[] args)
{
System.out.println(args[0]+args[1]);
}
}
/*
Output:- 1020
Explanation:- Because within the main() method command line arguments are available in the form of
String and if add two strings then it will perform concatination operation instead of addition.
*/

Read more »

What is the output of this program?

What is the output of this program?

class CommandLineArg2 { static public void main(String[] args) { String[] alt={"X","Y","Z"}; args=alt; for(int i=0;i<args.length;i++) { System.out.println(args[i]); } } } /*...

Read more »

What will be the output if we pass "A B C" as command line argument?

class CommandLineArg1
{
static public void main(String[] args)
{
for(int i=0;i<=args.length;i++)
{
System.out.println(args[i]);
}
}
}
/*
Output:-   A
B
               C
ArrayIndexOutOfBoundsException
Explanation:- If we replace "<=" with "<" then we will not get any Runtime Exception.
*/
Read more »

Which of the following valid main() method declarations?

Which of the following valid main() method declarations?

public static void main(String args) Invalid public static void Main(String[] args) Invalid public void main(String[] args) Invalid public static int...

Read more »