✦ Scientech Easy
Java Variables Quiz Test
📄
15
Questions
⏱
10 min
Time Limit
⭐
4
Marks / Q
−
1
Negative
‣ Read each question carefully before answering.
‣ Use the palette to navigate and bookmark questions.
‣ Wrong answers carry negative marks. Skipped = zero.
‣ The quiz auto-submits when the timer reaches zero.
‣ Stay in fullscreen mode throughout the quiz. Exiting fullscreen is detected and will result in auto-submission.
✦ Scientech Easy
Java Variables Quiz Test
15 Qs
Q 1
1 / 15
0s
Which statement is TRUE about variables in Java?
Variables must be declared before use.
Variables can be used without declaration.
Variables must always be initialized before declaration.
Variables don’t need data type.
Q 2
2 / 15
0s
Which of the following is a valid boolean assignment?
boolean b = 0;
boolean b = 1;
boolean b = “true”;
boolean b = true;
Q 3
3 / 15
0s
What is the default value of an int variable?
undefined
null
1
0
Q 4
4 / 15
0s
Which type of variable has block-level scope?
Instance variable
Static variable
Local variable
Global variable
Q 5
5 / 15
0s
What happens if a local variable is not initialized?
Runtime error
It becomes null.
Compilation error
It gets default value.
Q 6
6 / 15
0s
Which variable type is shared among all objects?
Static variable
Final variable
Instance variable
Local variable
Q 7
7 / 15
0s
What is a variable in Java?
A function
A fixed value
A container to store data
A keyword
Q 8
8 / 15
0s
What is the output of the program?
public class Q9 {
public static void main(String[] args) {
int x = 4;
int y = --x + x-- + ++x;
System.out.println(y);
}
}10
12
13
11
Q 9
9 / 15
0s
Which keyword is used to define variable scope?
private
All of these
public
protected
Q 10
10 / 15
0s
Which variable lives as long as the object exists?
Parameter Variable
Instance variable
Local variable
Static variable
Q 11
11 / 15
0s
Which of the following statement is TRUE for variables in Java?
All variables are stored in heap.
Static variables are stored in stack.
Java supports global variables.
Local variables are stored in stack.
Q 12
12 / 15
0s
What will be the output of the program?
package methodOverloading;
public class Multiplication
{
void multiply(int a, double b)
{
double m1 = a * b;
System.out.println("Multiplication of two numbers: " +m1);
}
void multiply(double a, int b)
{
double m2 = a * b;
System.out.println("Multiplication of two numbers: " +m2);
}
public static void main(String[] args)
{
Multiplication m = new Multiplication();
m.multiply(10, 20.5); // Calls multiply() to calculate the multiplication of two arguments int and double.
m.multiply(10.5, 30); // Calls multiply() to calculate the multiplication of two arguments double and int.
}
}
24
21
23
22
Q 13
13 / 15
0s
Which variable is created inside a method?
Global variable
Static variable
Local variable
Instance variable
Q 14
14 / 15
0s
Which keyword is used to declare a constant variable?
const
static
constant
final
Q 15
15 / 15
0s
Which of the following is a valid variable name?
value-1
value_1
1value
class
Time Left
00 : 10 : 00
Question Palette
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
Answered
Bookmarked
Not Visited
Finish Test?
You cannot change responses after submission.
⏱ Time's Up!
Your time is up. The quiz will be submitted.
⚠ Fullscreen Mode Exited
Quiz Complete!
Java Variables Quiz Test
Your Score
Correct
Wrong
Skipped
Total Q
Time Taken


