Page 323 - CA_Blue( J )_Class10
P. 323

8.  Which of the following is true about constructor overloading in Java?
                       a.  You can only have one constructor per class
                       b.  Constructors cannot be overloaded
                       c.  Constructors can have different parameters lists
                       d.  Constructors must have the same parameter lists
                    9.  Which keyword is used to call one constructor from another constructor in the same class?
                       a.  super                                       b.  this
                       c.  self                                        d.  constructor

                 B.  Answer the following questions:
                    1.  What is default constructor?
                    2.  Write the syntax to create an object of a class using constructor.
                    3.  What is the difference between parameterised and non-parameterised constructors?
                 C.  Assertion and Reasoning based questions.

                       The following questions consist of two statements – Assertion (A) and Reason (R). Answer these questions by selecting the
                       appropriate option given below:
                       a.  Both A and R are true, and R is the correct explanation of A.
                       b.  Both A and R are true, but R is not the correct explanation of A.
                       c.  A is true, but R is false.
                       d.  A is false, but R is true.
                    1.  Assertion (A): Constructor overloading helps in creating objects with different initial states.
                        Reason (R): Overloaded constructors are required to initialize all instance variables to default values.
                    2.  Assertion (A): Constructors do not have a return type.
                        Reason (R): Overloaded constructors only return void.
                    3.  Assertion (A): Using constructor overloading, a class can provide multiple ways to create objects with different initial data.
                        Reason (R): Overloaded constructors must have different names to allow the Java compiler to distinguish between them.

                                                                                                  21 st
                 D.  Case-based questions.                                                     Century   #Experiential Learning
                                                                                                 Skills
                       Default constructor: If a constructor is not defined in a class, then the java compiler provides a constructor which is known as
                       default constructor.
                        Parameterized constructor:  It is a type of constructor with parameters and statements inside its body. Number of parameter may
                       be different depending on the number of instance variables.
                    1.  What happens if a constructor is not defined in a class?
                       a.  The class cannot be instantiated.
                       b.  The Java compiler provides a default constructor.
                       c.  The Java runtime provides a default constructor.
                       d.  The class must be defined as abstract.
                    2.  What is a parameterized constructor in Java?
                       a.  A constructor without any parameters.
                       b.  A constructor with parameters and statements inside its body.
                       c.  A constructor that can only be called once.
                       d.  A constructor provided by the Java compiler.
                    3.  Which of the following is true about the number of parameters in a parameterized constructor?
                       a.  It must match the number of instance variables exactly.
                       b.  It can vary depending on the number of instance variables.
                       c.  It cannot exceed the number of instance variables.
                       d.  It must always be zero.
                    4.  What is the main purpose of a default constructor?
                       a.  To initialize instance variables with default values.
                       b.  To provide a mechanism for constructor overloading.
                       c.  To allow the class to be abstract.
                       d.  To perform complex initialization logic.

                                                                                                                       321
                                                                                                         Constructors  321
   318   319   320   321   322   323   324   325   326   327   328