Pretest for final exam Flashcards
T/F: In a class, fields can be any data type.
True
T/F: In a class, fields can only be primitive data types.
False
T/F: In a class, fields can only be user-defined data types.
False
T/F: In Java, a field is a variable inside a class but outside the methods of that class.
True
T/F: static variables declared in a class are also called class variables.
True
T/F: You create an object from a class blueprint.
True
T/F: In a method call, there must be exactly the same number of arguments in parentheses as there are formal parameters in the method header.
True
T/F: Inside a Java instance method, you can use the this keyword as a name for the calling object.
True
T/F: An instance variable that is declared private can be accessed by name outside of the class definition.
False
T/F: Mutator methods usually return void, but can return a boolean value indicating whether the change of the instance variable was a success.
True
T/F: Only the default constructor has access to the this parameter.
False
T/F: A main method can be placed inside any class definition
True
T/F: Primitive types are reference types.
False
T/F: Every class has a toString method and an equals method inherited from the Object class.
True
T/F: In a class, a field that is not declared static is called an instance variable.
True
T/F: static variables (or fields) of a class are shared by all instances of the class.
True
T/F: static variables (or fields) of a class can be accessed through the class name as well as an instance reference.
True
T/F: A static variable (or field) of a class is associated with the class itself rather than with any object of the class.
True
T/F: The new operator returns a reference to the object that was created.
True
T/F: When a program is running, the garbage collector automatically cleans up the objects
to which the program holds no more references.
True
T/F: You can use a static field to keep track of how many objects have been created from a particular class.
True
T/F: Any object can manipulate a class variable, but class variables can also be manipulated without creating an object of the class.
True
T/F: An instance method of a class can call a static method of the same class.
True
T/F: A constructor of a class can be declared private .
True
T/F: The Java compiler always adds a default constructor to a user defined class.
False
T/F: Each instantiated object will have its own copy of a class variable.
False
T/F: When an object is passed to a method, a copy of each of the object’s data members are created and passed to the method.
False
T/F: A class can have multiple constructors.
True
T/F: A formal parameter is a variable declared in the method header.
True
T/F: To use a predefined method you must know the code in the body of the method.
False
T/F: The word final is a return type in Java.
False
T/F: void methods never have parameters.
False
T/F: If a formal parameter is a variable of a primitive data type, then after copying the value of the actual argument, there is no connection between the formal parameter and the
actual argument.
True
T/F: You can use the class String to pass strings as parameters to a method and change the actual parameter.
True
T/F: Within a class, any instance method can call any other method, without exception.
True