Data Types in Java: Multiple Choice Questions (Tick The Correct Answers)
Data Types in Java: Multiple Choice Questions (Tick The Correct Answers)
Question 1
1. variable
2. literal
3. identifier
4. character
Question 2
1. "false"
2. true
3. false
4. "true"
Question 3
1. char variable
2. char type literal
3. string variable
4. string literal
Question 4
A character literal is enclosed in:
Question 5
1. String variable
2. Static variable
3. Boolean variable
4. None
Question 6
1. 65 - 90
2. 60 - 85
3. 65 - 91
4. 97 - 122
Question 7
1. Math.pow(a,2)
2. a*a
3. Math.sqrt(a,2)
4. All
Question 8
Question 9
Which of the following syntax is true to find the square root of a number?
1. sqrt(a)
2. Math.sqrt(a)
3. Squareroot(a)
4. None
Question 10
Boolean data is used to test a particular condition, i.e., true or false. Which
of the following is a correct representation?
1. boolean m = true
2. boolean m = 'true'
3. boolean m = "true"
4. none
Question 1
Write down the syntax for the following functions in Java programming:
Answer
Math.min(a, b)
Math.abs(a)
Answer
Math.exp(a)
Answer
Math.sqrt(a)
Question 2
Assign the value of pie () to a variable with the suitable data type.
Answer
double pi = 3.14159
Question 3
Answer
9.99
Answer
3.0
Question 4
Answer
double a = 35.0012;
Answer
double a = Math.sqrt(2);
Answer
double a = 435.0;
Answer
int a = 99;
double res = Math.sqrt(a);
Answer
int a = 23;
double res = Math.log(a);
Question 5
Correct the given snippet:
int a = 45.1;
float b = 15.05;
double c = 92;
sum = 0;
sum = (a+b)*c/2;
System.out.println("The answer ="+ans);
Answer
Corrected Program
Question 6
Question 1
Define a variable.
Answer
Question 2
Answer
Question 3
Answer
Question 4
Answer
(b) Interpreter
Answer
Answer
Question 5
Answer
Answer
Answer
Answer
Compiler Interpreter
It translates the whole source It translates the source program
program into target program at into target program one line at a
once. time.
All the errors found during Errors are displayed line by line
compilation are displayed as each line is translated and
together at once. executed.
Question 6
Primitive data types are the basic or fundamental data types used to
declare a variable. Examples of primitive data types in Java are byte,
short, int, long, float, double, char, boolean.
Question 7
Answer
Question 8
Answer
Question 9
Answer
In Java, a package is used to group related classes. Packages are of 2
types:
Question 10
Answer
int a = 10;
float b = 25.5f, c;
c = a + b;
int a = 10;
double b = 25.5;
float c = (float)(a + b);
Question 11
Answer
Question 12
Answer
int studentMarks;
StudentMarks = 85;