0% found this document useful (0 votes)
6 views3 pages

java Answer Key

The document contains an answer key for a Java Programming course exam at Shri G.P.M. Degree College of Science & Commerce. It includes 20 multiple-choice questions along with the correct answers related to Java programming concepts. The topics cover constants, data types, constructors, methods, threads, exceptions, and more.

Uploaded by

amangupta5123j
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
0% found this document useful (0 votes)
6 views3 pages

java Answer Key

The document contains an answer key for a Java Programming course exam at Shri G.P.M. Degree College of Science & Commerce. It includes 20 multiple-choice questions along with the correct answers related to Java programming concepts. The topics cover constants, data types, constructors, methods, threads, exceptions, and more.

Uploaded by

amangupta5123j
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1/ 3

Smt.

Shyampatidevi Mishra Educational Trust’s


SHRI G.P.M. DEGREE COLLEGE OF SCIENCE & COMMERCE
Affiliated to University of Mumbai www.shrigpmcollegeandheri.org shrigpm@gmail.com
Rajarshi Shahu Maharaj Road, Andheri (E), Mumbai – 400069. ✆ : 8928387197 / 8
Add on / Certificate Course : 2024 – 25
Answer Key
Course Name : Java Programming Department : IT
College Coordinator’s Name : Prof. Sahil Wade
Exam ____________ Max. Marks 20

Q. No.
1. Which of the following is used to define a constant in Java?
a) final
b) const
c) static
d) constant
Answer: a) final

2. What is the default value of a boolean variable in Java?


a) true
b) false
c) 0
d) null
Answer: b) false

3. Which of the following data types cannot be used to create an array in Java?
a) int
b) double
c) boolean
d) void
Answer: d) void

4. What is the size of an int in Java?


a) 16 bits
b) 32 bits
c) 64 bits
d) 128 bits
Answer: b) 32 bits

5. Which of these statements is true about constructors in Java?


a) A constructor has a return type.
b) A constructor cannot have parameters.
c) A constructor is called when an object is created.
d) A constructor must always be public.
Answer: c) A constructor is called when an object is created.

6. Which keyword is used to inherit a class in Java?


a) extends
b) inherits
c) super
d) implements
Answer: a) extends

7. Which of the following is a valid method signature in Java?


a) int 1method()
b) void method()!
c) boolean method(int x)
d) float method()&
Answer: c) boolean method(int x)
8. What is the output of the following Java code?
System.out.println(3 + 2 + "Hello");
a) 5Hello
b) Hello5
c) Hello32
d) 32Hello
Answer: a) 5Hello

9. Which method is used to start a thread execution in Java?


a) run()
b) start()
c) init()
d) execute()
Answer: b) start()

10. Which of the following classes is a subclass of Exception in Java?


a) Error
b) IOException
c) Throwable
d) RuntimeException
Answer: b) IOException

11. What does the final keyword indicate in Java?


a) The method can be overridden.
b) The variable's value cannot be modified.
c) The class can be subclassed.
d) The method can throw an exception.
Answer: b) The variable's value cannot be modified.

12. Which of the following is the parent class of all classes in Java?
a) Object
b) Class
c) Throwable
d) String
Answer: a) Object

13. What is the default value of an instance variable of type String in Java?
a) ""
b) null
c) 0
d) undefined
Answer: b) null

14. Which of the following statements about Java interfaces is false?


a) An interface can have methods with a body.
b) An interface can extend another interface.
c) A class can implement multiple interfaces.
d) An interface cannot be instantiated.
Answer: a) An interface can have methods with a body.

15. Which of the following methods is used to get the length of a string in Java?
a) length()
b) size()
c) getLength()
d) count()
Answer: a) length()

16. What is the output of the following Java code?


System.out.println(10 / 4);
a) 2.5
b) 2
c) 2.0
d) Error
Answer: b) 2

17. Which package is automatically imported in every Java program?


a) java.util
b) java.lang
c) java.io
d) java.net
Answer: b) java.lang

18. Which of the following operators is used to check equality in Java?


a) =
b) ==
c) ===
d) !=
Answer: b) ==

19. What does the super keyword refer to in Java?


a) The current class instance
b) The parent class
c) The current method
d) The current package
Answer: b) The parent class

20. Which of the following is the correct way to create an array of 10 integers in Java?
a) int[] arr = new int[10];
b) int arr = new int(10);
c) int arr = int[10];
d) int[10] arr = new int[];
Answer: a) int[] arr = new int[10];

You might also like