Professional Documents
Culture Documents
class Black {
public static void main(String[] args) {
short s1 = 1; //1
char c1 = 1; //2
byte b1 = s1; //3
byte b2 = c1; //4
final short s2 = 1; //5
final char c2 = 1; //6
byte b3 = s2; //7
byte b4 = c2; //8
}}
a. 1
b. 2
c. 3
d. 4
e. 5
f. 6
g. 7
h. 8
Question 2
class Magenta {
static byte a = (byte)127, b = (byte)128, c = (byte)255, d =
(byte)256;
public static void main(String args[]) {
System.out.print(a + " " + b + " " + c + " " + d);
}}
Question 3
class Primitives {
static void printFloat(float f) {System.out.println(f);}
static void printDouble(double d) {System.out.println(d);}
public static void main(String[] args) {
byte b = 1; // 1
short s = b; // 2
char c = s; // 3
int i = c; // 4
long l = i; // 5
float f = l; // 6
printFloat(i); // 7
printFloat(l); // 8
printDouble(l); // 9
}}
a. 1
b. 2
c. 3
d. 4
e. 5
f. 6
g. 7
h. 8
i. 9
j. None of the above
Question 4
class Maroon {
public static void main (String[] args) {
int a = 1; // 1
short b = 1; // 2
long c = 1; // 3
a = c + a; // 4
c = b + a; // 5
}}
a. 1
b. 2
c. 3
d. 4
e. 5
f. None of the above
Question 5
class Teal {
public static void main (String[] args) {
byte b = 1; // 1
long l = 1000; // 2
b += l; // 3
}}
a. 1
b. 2
c. 3
d. None of the above
Question 6
class Sienna {
static double a; static float b; static int c; static char d;
public static void main(String[] args) {
a = b = c = d = 'a';
System.out.println(a+b+c+d == 4 * 'a');
}}
Question 7
class UltraViolet {
public static void main (String[] args) {
char a = '\u002a', b = '\u0024'; // a = Asterisk *; b = Dollar Sign
$
System.out.print(a + b); // 1
System.out.print(" ABC" + a + b); // 2
}}