What is a default constructor?
A public method that takes no arguments and initializes instance variables.
Which of the following is a correct header for a constructor for a class called Employee
?
1 public Employee(String name)
Only one constructor may be defined per class.
False
If no constructors are defined for a class, Java will automatically define a default constructor.
True
Given a class called Rectangle
with a constructor that takes two doubles as arguments representing the dimensions, which of the following is the correct way to invoke that constructor?
1 Rectangle rect = new Rectangle(8.2, 3.5);
What is the difference between a static variable and an instance variables?
A static variable is shared by all objects of a class. Every object has its own version of an instance variable.
Which of the following is not allowed in Java?
A static method calling a nonstatic method of the same class without an object to call it on.
An import statement is required to use the java Math
class.
False
What is a wrapper class?
A class that provides methods for manipulating a primitive type.
Every wrapper class has a default constructor.
False