Show List

Quiz - Java Data Types and Variables - 1

65%

Public Average Score
Select the right answer for below questions:

What is the default value of a local variable in Java?
0
null
undefined
None of the above
undefined

What is the range of the short data type in Java?
-32768 to 32767
-2147483648 to 2147483647
-128 to 127
None of the above
-32768 to 32767

What is the correct syntax for declaring a variable in Java?
var x;
int x;
x as int;
None of the above
int x;

What is the difference between a final variable and a constant in Java?
There is no difference, both terms can be used interchangeably.
A constant must be defined in all caps, while a final variable does not have this requirement.
A constant is a variable declared with the final keyword, while a final variable is a variable that can only be assigned once.
None of the above
A constant is a variable declared with the final keyword, while a final variable is a variable that can only be assigned once.

What is the correct syntax for declaring a class in Java?
class myClass
class MyClass
Class myClass
None of the above
class MyClass

What is the difference between a static variable and a non-static variable in Java?
A static variable is shared among all objects of a class, while a non-static variable is unique to each object.
A static variable is unique to each object, while a non-static variable is shared among all objects of a class.
There is no difference between the two.
None of the above.
A static variable is shared among all objects of a class, while a non-static variable is unique to each object.

What is the range of the byte data type in Java?
-32768 to 32767
-128 to 127
-2147483648 to 2147483647
None of the above
-128 to 127

What is the default value of a boolean variable in Java?
FALSE
TRUE
0
null
FALSE

What is the correct syntax for declaring an array in Java?
int[] myArray;
myArray[] as int;
var myArray[];
None of the above
int[] myArray;

What is the difference between a public and private variable in Java?
A public variable can be accessed from anywhere in the program, while a private variable can only be accessed within the same class.
A private variable can be accessed from anywhere in the program, while a public variable can only be accessed within the same class.
There is no difference between the two.
None of the above.
A public variable can be accessed from anywhere in the program, while a private variable can only be accessed within the same class.

Submit
Retry
{"qz1-538921":"undefined","qz1-538922":"-32768 to 32767","qz1-538923":"int x;","qz1-538924":"A constant is a variable declared with the final keyword, while a final variable is a variable that can only be assigned once.","qz1-538925":"class MyClass","qz1-538926":"A static variable is shared among all objects of a class, while a non-static variable is unique to each object.","qz1-538927":"-128 to 127","qz1-538928":"FALSE","qz1-538929":"int[] myArray;","qz1-538930":"A public variable can be accessed from anywhere in the program, while a private variable can only be accessed within the same class."}

    Leave a Comment


  • captcha text