fundamental of java programming coursera week 3 quiz answers
OOPS - Practice Quiz
1. What is the main difference between Object-Oriented Programming (OOPs), Functional Programming, and Procedural Programming?
- OOPs focuses on objects and classes, while Functional Programming focuses on functions and immutability, and Procedural Programming focuses on procedures and routines.
- OOPs is only used in Java, while Functional Programming and Procedural Programming are used in other programming languages.
- OOPs uses inheritance, while Functional Programming and Procedural Programming do not.
- OOPs is a deprecated programming paradigm, while Functional Programming and Procedural Programming are widely used.
2. What are classes and objects in Java?
- Classes are instances of objects.
- Objects are instances of classes.
- Classes and objects are the same thing in Java.
- Classes and objects are not used in Java.
3. What are access modifiers in Java?
- Keywords used to define mathematical operations in Java.
- Keywords used to define the visibility and accessibility of class members (variables, methods, inner classes) in Java.
- Keywords used to define the data types in Java.
- Keywords used to define loops and conditional statements in Java.
4. What is a wrapper class in Java?
- A class that wraps objects and provides access to their methods and properties.
- A class that provides utility methods for working with arrays.
- A class that provides access to input/output operations.
- A class that provides methods for encryption and decryption of data.
5. What is the purpose of the "this" keyword in Java?
- To refer to the current instance of the class within a method or constructor.
- To create a new instance of a class.
- To refer to the parent class in case of inheritance.
- To specify the return type of a method.
Constructors - Practice Quiz
6. What is a constructor in Java?
- A method used to copy the values of one object to another.
- A method used to define the behavior of an object.
- A special method used to create and initialize objects of a class.
- A method used to define the properties of an object.
7. What is a copy constructor in Java?
- A constructor used to create a deep copy of an object.
- A constructor used to create a shallow copy of an object.
- A constructor used to create a new object from an existing object.
- A constructor used to create an object from a different class.
8. What is constructor chaining in Java?
- A way to chain multiple constructors together to create a complex object.
- A way to call a constructor of a different class.
- A process where one constructor calls another constructor of the same class using “this” keyword.
- A way to create a constructor with multiple parameters.
9. What is the purpose of a private constructor in Java?
- To prevent instantiation of the class.
- To allow multiple instances of the class.
- To make the class accessible from any package.
- To enable inheritance of the class.
10. What is a singleton class in Java?
- A class that can have multiple instances.
- A class that can have only one instance throughout the lifetimeof an application.
- A class that cannot have any instance.
- A class that can be instantiated from any package.