Programming  Java  Variables

1. What is the output of this program?
class conversion {
public static void main(String args[])
{
double a = 295.04;
int b = 300;
byte c = (byte) a;
byte d = (byte) b;
System.out.println(c + " " + d.;
}
}

38 43 39 44 295 300 295.04 300

2. What is the output of this program?
class increment {
public static void main(String args[])
{
int g = 3;
System.out.print(++g * 8);
}
}

25 24 32 33

3. What is the output of this program?
class area {
public static void main(String args[])
{
double r, pi, a;
r = 9.8;
pi = 3.14;
a = pi * r * r;
System.out.println(a);
}
}

301.5656 301 301.56 301.56560000

4. What is the numerical range of a char in Java?

-128 to 127 0 to 256 0 to 32767 0 to 65535

5. Which of these coding types is used for data type characters in Java?

ASCII ISO-LATIN-1 UNICODE None of the mentioned

6. Which of these values can a boolean variable contain?

True & False 0 & 1 Any integer value true

7. Which of these occupy first 0 to 127 in Unicode character set used for characters in Java?

ASCII ISO-LATIN-1 None of the mentioned ASCII and ISO-LATIN1

8. Which one is a valid declaration of a boolean?

boolean b1 = 1; boolean b2 = ‘false’; boolean b3 = false; boolean b4 = ‘true’

9. What is the output of this program?
class array_output {
public static void main(String args[])
{
char array_variable [] = new char[10];
for (int i = 0; i < 10; ++i) {
array_variable[i] = i;
System.out.print(array_variable[i] + "" );
i++;
}
}
}

i i i i i 0 1 2 3 4 i j k l m None of the mentioned

10. What is the output of this program?
class mainclass {
public static void main(String args[])
{
char a = A;
a++;
System.out.print((int)a);
}
}

66 67 65 64

 

*Click on the QNo to display a Question.

Total Ans

 

 

';
Aptitude Coaching - Free Live Session !!