Object Oriented System Design Questions and Answers – Integers

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

Answer: c
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

Answer: b
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

Answer: a
Explanation: None.
advertisement
advertisement

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

Answer: c
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

Answer: d
Explanation: None.

6. Which of the following is default value of ‘int’ data type?
a) 0
b) null
c) true
d) false
View Answer

Answer: a
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

Answer: b
Explanation: Default value is assigned to a variable by memory when it is declared but not initialized.
advertisement

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

Answer: d
Explanation: None.

9. What is the output of the program?

advertisement
  1. class Test
  2. { 
  3.     public static void main(String args[])
  4.     { 
  5.         int a = 12;
  6.         int b = 0;
  7.         int c = a/b;
  8.         System.out.println("The value of c is"+c);
  9.     }
  10. }

a) Compilation error
b) Run time error
c) The value of c is 0
d) None of the mentioned
View Answer

Answer: b
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

Answer: a
Explanation: None.

Sanfoundry Global Education & Learning Series – Object Oriented System Design.

Here’s the list of Best Books in Object Oriented System Design.

To practice all areas of Objection Oriented System Design, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.