0% found this document useful (0 votes)
13 views3 pages

Day 2 - Activity 02

The document contains 10 multiple choice questions about Java programming basics such as primitive data types, operators, and variable initialization. It tests knowledge of integer ranges, arithmetic operations, and relational/boolean operators in Java code snippets.

Uploaded by

dilankasilva86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views3 pages

Day 2 - Activity 02

The document contains 10 multiple choice questions about Java programming basics such as primitive data types, operators, and variable initialization. It tests knowledge of integer ranges, arithmetic operations, and relational/boolean operators in Java code snippets.

Uploaded by

dilankasilva86
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Activity 2 – Day 2

1) How many primitive data types in JAVA?

1) 6
2) 8
3) 4
4) 2

2) In Java byte, short, int and long all these are?


________________________________________

3) What is the output of java code snippet below?

char Charvar = 'a';

System.out.println(Charvar);

System.out.println((int) Charvar); //Return ASCII Value

4) Print the ASCII value of the character 'V'.


________________________________________

5) What is the output of java code snippet below?

int no1 = 500;


int no2 =76;
int ans = no1 + no2 + 43 + 9;

System.out.println(ans);

6) Size of short is?

A) 8 - bits
B) 16 - bits
C) 32 - bits
D) 64 - bits
7) Range of byte is?

A) -128 to +128
B) -128 to +129
C) - 32102 to +32102
D) -127 to +127

8) What is the output of java code snippet below?

public class Value {


public static void main(String[] args) {
int x = 15;
int y = x % 4;
int z = y * 24;
System.out.println(z / 2);
System.out.println(z);
System.out.println(x+z);
System.out.println(y);

}
}

9) What is the output of java code snippet below?

public class Test {


public static void main(String args[]) {
int a = 10;
int b = a - 5;
System.out.println(a <= b);
System.out.println(a > b);
}
}
9) What is the output of java code snippet below?

public class Relation {


public static void main(String args[]) {
int a = 15;
int b = a + 5;
int c = a + 10;
int d = c % a;
float h = 2.5f;
double J = 6.5d;
boolean booleanstatus = true;

System.out.println(d);
System.out.println(h+a);
System.out.println(d+c);
}
}

10) What are the correct ways to initialize - x, y and z to 100.

A) int x = 100;
int y = 100;
int z = 100;

B) int x = 100, y = 100, z = 100;

C) int x = y = z = 100;

D) int x, y, z = 100;
x = y = z;

E) int x, y, z;
x = y = z = 100;

You might also like