MCQOPTIONS
Saved Bookmarks
This section includes 21 Mcqs, each offering curated multiple-choice questions to sharpen your Object Oriented Programming knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
Which is correct syntax? |
| A. | classname objectname= new() integer; |
| B. | classname objectname= new classname; |
| C. | classname objectname= new classname(); |
| D. | classname objectname= new() classname(); |
| Answer» D. classname objectname= new() classname(); | |
| 2. |
What are we only create an object but don’t call any constructor for it in java? |
| A. | Implicit constructor will be called |
| B. | Object is initialized to some null values |
| C. | Object is not created |
| D. | Object is created but points to null |
| Answer» E. | |
| 3. |
Which constructor will be called from the object obj2 in the following program? |
| A. | A(int x) |
| B. | A(int y) |
| C. | A(int y, int x) |
| D. | A(int y; int x)View Answer |
| Answer» D. A(int y; int x)View Answer | |
| 4. |
Which among the following is not valid in java? |
| A. | Constructor overloading |
| B. | Recursive constructor call |
| C. | Default value constructors |
| D. | String argument constructor |
| Answer» C. Default value constructors | |
| 5. |
If programmer have defined parameterized constructor only, then __________________ |
| A. | Default constructor will not be created by the compiler implicitly |
| B. | Default constructor will be created by the compiler implicitly |
| C. | Default constructor will not be created but called at runtime |
| D. | Compile time error |
| Answer» B. Default constructor will be created by the compiler implicitly | |
| 6. |
Why do we use constructor overloading? |
| A. | To use different types of constructors |
| B. | Because it’s a feature provided |
| C. | To initialize the object in different ways |
| D. | To differentiate one constructor from another |
| Answer» D. To differentiate one constructor from another | |
| 7. |
Which among the following function can be used to call default constructor implicitly in java? |
| A. | this() |
| B. | that() |
| C. | super() |
| D. | sub() |
| Answer» B. that() | |
| 8. |
When is the constructor called for an object? |
| A. | As soon as overloading is required |
| B. | As soon as class is derived |
| C. | As soon as class is created |
| D. | As soon as object is created |
| Answer» E. | |
| 9. |
Which among the following is false for a constructor? |
| A. | Constructors doesn’t have a return value |
| B. | Constructors are always user defined |
| C. | Constructors are overloaded with different signature |
| D. | Constructors may or may not have any arguments being accepted |
| Answer» C. Constructors are overloaded with different signature | |
| 10. |
Which constructor will be called from the object created in the code below? |
| A. | Default constructor |
| B. | Parameterized constructor |
| C. | Compile time error |
| D. | Run time errorView Answer |
| Answer» D. Run time errorView Answer | |
| 11. |
Which among the following is possible way to overload constructor? |
| A. | Define default constructor, 1 parameter constructor and 2 parameter constructor |
| B. | Define default constructor, zero argument constructor and 1 parameter constructor |
| C. | Define default constructor, and 2 other parameterized constructors with same signature |
| D. | Define 2 default constructors |
| Answer» B. Define default constructor, zero argument constructor and 1 parameter constructor | |
| 12. |
Does constructor overloading include different return types for constructors to be overloaded? |
| A. | Yes, if return types are different, signature becomes different |
| B. | Yes, because return types can differentiate two functions |
| C. | No, return type can’t differentiate two functions |
| D. | No, constructors doesn’t have any return type |
| Answer» E. | |
| 13. |
Can constructors be overloaded in derived class? |
| A. | Yes, always |
| B. | Yes, if derived class has no constructor |
| C. | No, programmer can’t do it |
| D. | No, never |
| Answer» E. | |
| 14. |
Which among the following best describes constructor overloading? |
| A. | Defining one constructor in each class of a program |
| B. | Defining more than one constructor in single class |
| C. | Defining more than one constructor in single class with different signature |
| D. | Defining destructor with each constructor |
| Answer» D. Defining destructor with each constructor | |
| 15. |
WHY_DO_WE_USE_CONSTRUCTOR_OVERLOADING??$ |
| A. | To use different types of constructors |
| B. | Because it’s a feature provided |
| C. | To initialize the object in different ways |
| D. | To differentiate one constructor from another |
| Answer» B. Because it‚Äö√Ñ√∂‚àö√ë‚àö¬•s a feature provided | |
| 16. |
WHICH_AMONG_THE_FOLLOWING_FUNCTION_CAN_BE_USED_TO_CALL_DEFAULT_CONSTRUCTOR_IMPLICITLY_IN_JAVA??$ |
| A. | this() |
| B. | that() |
| C. | super() |
| D. | sub() |
| Answer» D. sub() | |
| 17. |
Which among the following is not valid in java?$ |
| A. | Constructor overloading |
| B. | Recursive constructor call |
| C. | Default value constructors |
| D. | String argument constructor |
| Answer» D. String argument constructor | |
| 18. |
If programmer have defined parameterized constructor only, then __________________$ |
| A. | Default constructor will not be created by the compiler implicitly |
| B. | Default constructor will be created by the compiler implicitly |
| C. | Default constructor will not be created but called at runtime |
| D. | Compile time error |
| Answer» C. Default constructor will not be created but called at runtime | |
| 19. |
What is we only create an object but don’t call any constructor for it in java?$ |
| A. | Implicit constructor will be called |
| B. | Object is initialized to some null values |
| C. | Object is not created |
| D. | Object is created but points to null |
| Answer» D. Object is created but points to null | |
| 20. |
A(int x) |
| A. | A(int y) |
| B. | A(int y, int x) |
| C. | A(int y; int x) |
| Answer» B. A(int y, int x) | |
| 21. |
Default constructor |
| A. | Parameterized constructor |
| B. | Compile time error |
| C. | Run time error |
| Answer» C. Run time error | |