Study

Constructors

  •   0%
  •  0     0     0

  • Which statement calls a constructor with no construction parameters?
    Circle c = new Circle();
  • True or False: Private instance variables are the interface to the class.
    False
  • True or False: A call to a constructor must always have construction parameters.
    False
  • True or False: A constructor should always return a value.
    False
  • What is wrong with this code?
    The constructor must not have a return type declared.
  • True or False: All instance variables should be declared as private and most instance methods should be declared as public
    True
  • True or False: A constructor must have the same name as the class name.
    True
  • True or False: A class can have more than one constructor.
    True
  • True or False: A class can have only one constructor.
    False
  • You are creating a class named Employee. What is the statement that correctly declares a constructor for this class?
    public Employee()
  • When an object is created from a class, the object is called a/an ________ of the class.
    instance
  • A constructor is invoked when _________________ to create an object.
    the new keyword is used
  • If you do not provide a constructor in a class, which of the following is correct?
    The compiler will generate a constructor with no arguments.
  • True or False: A constructor initializes the instance variables of an object.
    True
  • You have created a Motorcycle class which has a constructor with no parameters. Which of the following statements will construct an object of this class?
    Motorcycle myBike = new Motorcycle();