This set of Object Oriented System Design Multiple Choice Questions & Answers (MCQs) focuses on “Integers”.
1. Which of the following data type is used to fetch stream of data from network or file?
a) char
b) int
c) byte
d) double
View Answer
Explanation: when input is taken from keyboard or file it is taken in the form of bits by the machine. Byte is a collection of bits that makes user read a character at the output at a time. Usage of byte also saves memory.
2. What is the size(in bytes) of ‘byte’ primitive data type?
a) 4
b) 1
c) 2
d) 8
View Answer
Explanation: ‘byte’ is a signed 8-bit(1byte) data type defined by Java.
3. What is the minimum value of ‘short’ data type?
a) -32,768
b) -127
c) -2,147,483,648
d) -32,767
View Answer
Explanation: None.
4. What is the maximum value of ‘byte’ data type?
a) 2^7
b) 2^7+1
c) 2^7-1
d) None of the mentioned
View Answer
Explanation: None.
5. What is the range of ‘short’ data type?
a) -(2^15+1) to (2^15-1)
b) -2^15 to 2^15
c) -(2^15-1) to (2^15+1)
d) -(2^15-1) to 2^15
View Answer
Explanation: None.
6. Which of the following is default value of ‘int’ data type?
a) 0
b) null
c) true
d) false
View Answer
Explanation: Default value is assigned to a variable by memory when it is declared but not initialized.
7. Which of the following is default value of ‘double’ data type?
a) 0
b) 0.0d
c) null
d) false
View Answer
Explanation: Default value is assigned to a variable by memory when it is declared but not initialized.
8. What is the range of ‘byte’ data type?
a) -127 to 127
b) -128 to 127
c) -127 to 128
d) -128 to 127
View Answer
Explanation: None.
9. What is the output of the program?
class Test
{
public static void main(String args[])
{
int a = 12;
int b = 0;
int c = a/b;
System.out.println("The value of c is"+c);
}
}
a) Compilation error
b) Run time error
c) The value of c is 0
d) None of the mentioned
View Answer
Explanation: The above code results in Exception in thread main.Division by zero is not defined in Java.
10. Which of the following is not considered as data type in Java?
a) String
b) int
c) boolean
d) double
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – Object Oriented System Design.
Here’s the list of Best Books in Object Oriented System Design.
If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]