Miscellaneous In Java - Study Mode

[#96] What is the output of the following code in Java? `System.out.println("Hello" + 1 + 2 + 3)
`
Correct Answer

(C) Hello123

[#97] What is the default value of a local variable in Java if it is not explicitly initialized?
Correct Answer

(D) There is no default value it must be initialized before use

[#98] What will be the output of the following Java program, Command line execution is done as - java Output "This is a command Line"? class Output
{
public static void main(String args[])
{
for (String arg : args)
{
System.out.print(arg)
}
}
}
Correct Answer

(C) This is a command Line

[#99] What will be the output of the following Java snippet, if attempted to compile and execute? class abc
{
public static void main(String args[])
{
if(args.length>0)
System.out.println(args.length)
}
}
Correct Answer

(D) The snippet compiles and runs but does not print anything

[#100] What will be the output of the following Java program? class static_out
{
static int x
static int y
void add(int a , int b)
{
x = a + b
y = x + b
}
}
class static_use
{
public static void main(String args[])
{
static_out obj1 = new static_out()
static_out obj2 = new static_out()
int a = 2
obj1.add(a, a + 1)
obj2.add(5, a)
System.out.println(obj1.x + " " + obj2.y)
}
}
Correct Answer

(C) 7 9