Programming  Java  Variables

31. What is the output of this program?
class mainclass {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
if (var1)
System.out.println(var1);
else
System.out.println(var2);
}
}

0 1 true false

Workspace

Comments

32. What is the output of this program?
class booloperators {
public static void main(String args[])
{
boolean var1 = true;
boolean var2 = false;
System.out.println((var2 & var2));
}
}

0 1 true false

Workspace

Comments

33. What is the output of this program?
class asciicodes {
public static void main(String args[])
{
char var1 = A;
char var2 = a;
System.out.println((int)var1 + " " + (int)var2);
}
}

162 65 97 67 95 66 98

Workspace

Comments

34. Which of these is data type long literal?

0x99fffL ABCDEFG 0x99fffa 99671246

Workspace

Comments

35. Which of these can be returned by the operator & ?

Integer Boolean Character Integer or Boolean

Workspace

Comments

36. Literals in java must be preceded by which of these?

L l D L and l

Workspace

Comments

37. Literal can be of which of these data types?

integer float boolean all of the mentioned

Workspace

Comments

38. Which of these can not be used for a variable name in Java?

identifier keyword identifier & keyword None of the mentioned

Workspace

Comments

39. What is the output of this program?
class evaluate {
public static void main(String args[])
{
int a[] = {1,2,3,4,5};
int d[] = a;
int sum = 0;
for (int j = 0; j < 3; ++j)
sum += (a[j] * d[j + 1]) + (a[j + 1] * d[j]);
System.out.println(sum);
}
}

38 39 40 41

Workspace

Comments

40. Which of these is incorrect string literal?

“Hello World” “Hello” “World” ab12

Workspace

Comments

 

*Click on the QNo to display a Question.

Total Ans