0% found this document useful (0 votes)
99 views8 pages

Unit-04 Java MCQ - 16944662 - 2023 - 03 - 24 - 19 - 51

This document contains a quiz on object-oriented programming concepts in Java like classes, objects, methods, and constructors. It asks multiple choice questions to test understanding of topics such as: - The definition of a class and object - Characteristics of objects like state and behavior - How objects are created using the new keyword - Instance variables that get memory at runtime - The Object class being a superclass of all classes - Constructors and how they initialize objects - Overloading and overriding methods and constructors - Garbage collection techniques like mark-and-sweep

Uploaded by

Ujjwal Dubey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
99 views8 pages

Unit-04 Java MCQ - 16944662 - 2023 - 03 - 24 - 19 - 51

This document contains a quiz on object-oriented programming concepts in Java like classes, objects, methods, and constructors. It asks multiple choice questions to test understanding of topics such as: - The definition of a class and object - Characteristics of objects like state and behavior - How objects are created using the new keyword - Instance variables that get memory at runtime - The Object class being a superclass of all classes - Constructors and how they initialize objects - Overloading and overriding methods and constructors - Garbage collection techniques like mark-and-sweep

Uploaded by

Ujjwal Dubey
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1 CTH EDUCATION

Unit – 04: Classes and methods

1. What is an object in Java?


a) static reference
b) template or blueprint
c) instance of class
d) None of above
Answer: C

2. Which are the object characteristics?


a) State
b) Behavior
c) Identity
d) All of above
Answer: D

3. State characteristic of an object represents


a) the data of an object
b) the behaviors or actions of an object
c) the internal unique identity of an object
d) All of above
Answer: A

4. Behavior characteristic of an object represents


a) the data of an object
b) the behaviors or actions of an object
c) the internal unique identity of an object
d) All of above
Answer: B

5. Which is the best definition of an object?


a) An object is a real-world entity
b) An object is a runtime entity
c) The object is an instance of a class
d) All of above
Answer: D

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
2 CTH EDUCATION
6. A variable, which gets memory at runtime when an object is created is called?
a) static variable
b) local variable
c) instance variable
d) all of the above
Answer: C

7. new keyword is used for?


a) allocating memory at runtime
b) allocating memory at compile time
c) releasing memory at runtime
d) All of above
Answer: A

8. An object can be initialize in Java by?


a) reference variable
b) method
c) constructor
d) All of above
Answer: D

9. What are the different ways to create an object in Java?


a) by new keyword
b) by newInstance() or clone() method
c) by deserialization & factory method
d) All of Above
Answer: D

10. What is a class in Java?


a) static reference
b) template or blueprint
c) instance of class
d) None of above
Answer: B

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
3 CTH EDUCATION
11. The keyword __________ is required to declare a class.
a) Public
b) Private
c) Class
d) All of the above
Answer: C

12. A Java class can have


a) Fields and Methods
b) Constructors and Blocks
c) Nested class and interface
d) All of above
Answer: D

13. A variable which doesn't get memory at compile time is called?


a) static variable
b) local variable
c) instance variable
d) All of the above
Answer: C

14. Which of these class is superclass of every class in Java?


a) String class
b) Object class
c) Abstract class
d) ArrayList class
Answer: b

15. Which of these keywords can be used to prevent inheritance of a class?


a) super
b) constant
c) class
d) final
Answer: d

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
4 CTH EDUCATION
16. A Java constructor is like a method without ___.
a) statements
b) return type
c) argument list
d) None
Answer: B

17. The name of a constructor and the name of a class are ___.
a) Same
b) Different
c) -
d) -
Answer: A

18. The placement of a constructor inside a class should be ___.


a) Always at the beginning of class
b) Always at the end of class
c) Anywhere in the class
d) None
Answer: C

19. The purpose of a Java constructor is ___.


a) Initialization of variables with passed data
b) Writing custom code
c) Accepting other objects as inputs
d) All the above
Answer: D

20. Memory is allocated to an object once the execution of ___ is over in Java language.
a) main method
b) constructor
c) destructor
d) None
Answer: B

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
5 CTH EDUCATION
21. In Java, a constructor with no parameters or no arguments is called ___ constructor.
a) Default constructor
b) User-defined constructor
c) -
d) -
Answer: A

22. In Java, a constructor with one or more arguments or parameters is called a ___
constructor.
a) Default constructor
b) User-defined constructor or Non-default constructor
c) -
d) -
Answer: B

23. The compiler adds a default no-argument constructor to a class if it ___.


a) does not define a constructor at all.
b) defines at least one constructor with arguments
c) -
d) -
Answer: A

24. Overloading of constructors in Java means adding more than ___ constructors with the
different argument list.
a) 1
b) 2
c) 3
d) 8
Answer: A

25. A constructor can call another overloaded constructor using the ___ keyword in Java.
a) super
b) local
c) con
d) this
Answer: D

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
6 CTH EDUCATION
26. In Java, you can pass __ variables from one constructor to another overloaded
constructor.
a) local variables
b) static variables
c) non-static variables
d) local and static variables
Answer: D

27. What is false about constructor?


a) Constructors cannot be synchronized in Java
b) Java does not provide default copy constructor
c) Constructor can have a return type
d) “this” and “super” can be used in a constructor
Answer: c

28. What is true about constructor?


a) It can contain return type
b) It can take any number of parameters
c) It can have any non access modifiers
d) Constructor cannot throw an exception
Answer: b

29. What is not the use of “this” keyword in Java?


a) Passing itself to another method
b) Calling another constructor in constructor chaining
c) Referring to the instance variable when local variable has the same name
d) Passing itself to method of the same class
Answer: d

30. What would be the behaviour if one parameterized constructor is explicitly defined?
a) Compilation error
b) Compilation succeeds
c) Runtime error
d) Compilation succeeds but at the time of creating object using default constructor, it throws
compilation error
Answer: d

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
7 CTH EDUCATION
31. What would be behaviour if the constructor has a return type?
a) Compilation error
b) Runtime error
c) Compilation and runs successfully
d) Only String return type is allowed
Answer: a

32. What is the process of defining two or more methods within same class that have same
name but different parameters declaration?
a) method overloading
b) method overriding
c) method hiding
d) none of the mentioned
Answer: a

33. Which of these can be overloaded?


a) Methods
b) Constructors
c) All of the mentioned
d) None of the mentioned
Answer: c

34. What is the process of defining a method in terms of itself, that is a method that calls
itself?
a) Polymorphism
b) Abstraction
c) Encapsulation
d) Recursion
Answer: d

35. Which of the following has the highest memory requirement?


a) Heap
b) Stack
c) JVM
d) Class
Answer: c

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)
8 CTH EDUCATION
36. Which of the following is a garbage collection technique?
a) Cleanup model
b) Mark and sweep model
c) Space management model
d) Sweep model
Answer: b

37. What happens to the thread when garbage collection kicks off?
a) The thread continues its operation
b) Garbage collection cannot happen until the thread is running
c) The thread is paused while garbage collection runs
d) The thread and garbage collection do not interfere with each other
Answer: c

38. Where is a new object allocated memory?


a) Young space
b) Old space
c) Young or Old space depending on space availability
d) JVM
Answer: a

39. What is the return type of a method that does not return any value?
a) int
b) float
c) void
d) double
Answer: c

40. Which method can be defined only once in a program?


a) main method
b) finalize method
c) static method
d) private method
Answer: a

Diploma : CSE (All Paper) By : Alok Sir (Mob. No.: +91-80 84 370 470)

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy