✦ 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 keyword is used to define variable scope?
public
protected
private
All of these
Q 2
2 / 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);
}
}11
12
10
13
Q 3
3 / 15
0s
Which keyword is used to declare a constant variable?
constant
final
const
static
Q 4
4 / 15
0s
Which variable lives as long as the object exists?
Static variable
Parameter Variable
Local variable
Instance variable
Q 5
5 / 15
0s
Which of the following is a valid boolean assignment?
boolean b = “true”;
boolean b = true;
boolean b = 0;
boolean b = 1;
Q 6
6 / 15
0s
What is a variable in Java?
A function
A keyword
A fixed value
A container to store data
Q 7
7 / 15
0s
Which statement is TRUE about variables in Java?
Variables can be used without declaration.
Variables must always be initialized before declaration.
Variables must be declared before use.
Variables don’t need data type.
Q 8
8 / 15
0s
Which variable is created inside a method?
Global variable
Static variable
Local variable
Instance variable
Q 9
9 / 15
0s
Which variable type is shared among all objects?
Instance variable
Static variable
Final variable
Local variable
Q 10
10 / 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.
}
}
23
21
24
22
Q 11
11 / 15
0s
What happens if a local variable is not initialized?
It gets default value.
Compilation error
Runtime error
It becomes null.
Q 12
12 / 15
0s
Which of the following statement is TRUE for variables in Java?
Static variables are stored in stack.
All variables are stored in heap.
Java supports global variables.
Local variables are stored in stack.
Q 13
13 / 15
0s
Which type of variable has block-level scope?
Instance variable
Local variable
Global variable
Static variable
Q 14
14 / 15
0s
Which of the following is a valid variable name?
value_1
1value
value-1
class
Q 15
15 / 15
0s
What is the default value of an int variable?
null
undefined
0
1
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


