Show List
Quiz - Java Data Types and Variables - 2
Select the right answer for below questions:
What is the range of the int data type in Java?
-32768 to 32767
-2147483648 to 2147483647
-128 to 127
None of the above
-2147483648 to 2147483647
What is the difference between a primitive data type and a reference data type in Java?
A primitive data type is a basic data type that holds values, while a reference data type holds a reference to an object.
A reference data type is a basic data type that holds values, while a primitive data type holds a reference to an object.
There is no difference between the two.
None of the above.
A primitive data type is a basic data type that holds values, while a reference data type holds a reference to an object.
What is the default value of a static variable in Java?
0
null
undefined
None of the above
null
What is the correct syntax for declaring a constant in Java?
final x;
const x;
final int x;
None of the above
final int x;
What is the difference between a method and a constructor in Java?
A method is a block of code that performs a specific task, while a constructor is a special type of method that is used to create an object of a class.
A constructor is a block of code that performs a specific task, while a method is a special type of constructor that is used to create an object of a class.
There is no difference between the two.
None of the above.
A method is a block of code that performs a specific task, while a constructor is a special type of method that is used to create an object of a class.
What is the default value of an instance variable in Java?
0
undefined
null
None of the above
null
What is the difference between a local variable and an instance variable in Java?
There is no difference between the two.
An instance variable is declared within a method, while a local variable is declared within a class but outside of any method.
A local variable is declared within a method, while an instance variable is declared within a class but outside of any method.
None of the above.
A local variable is declared within a method, while an instance variable is declared within a class but outside of any method.
What is the range of the short data type in Java?
-32768 to 32767
-128 to 127
-2147483648 to 2147483647
None of the above
-32768 to 32767
What is the correct syntax for declaring a char variable in Java?
char myChar;
char = 'a';
myChar as char;
None of the above
char myChar;
What is the difference between a while loop and a do-while loop in Java?
A while loop only executes its code block if its condition is true, while a do-while loop executes its code block at least once, and then repeats as long as its condition is true.
A do-while loop only executes its code block if its condition is true, while a while loop executes its code block at least once, and then repeats as long as its condition is true.
There is no difference between the two.
None of the above.
A while loop only executes its code block if its condition is true, while a do-while loop executes its code block at least once, and then repeats as long as its condition is true.
Submit
Retry
{"qz1-314079":"-2147483648 to 2147483647","qz1-314080":"A primitive data type is a basic data type that holds values, while a reference data type holds a reference to an object.","qz1-314081":"null","qz1-314082":"final int x;","qz1-314083":"A method is a block of code that performs a specific task, while a constructor is a special type of method that is used to create an object of a class.","qz1-314084":"null","qz1-314085":"A local variable is declared within a method, while an instance variable is declared within a class but outside of any method.","qz1-314086":"-32768 to 32767","qz1-314087":"char myChar;","qz1-314088":"A while loop only executes its code block if its condition is true, while a do-while loop executes its code block at least once, and then repeats as long as its condition is true."}
Leave a Comment