Java: Chapter 3

Ace your homework & exams now with Quizwiz!

The format specifier ________ is used to output values of type float or double. - %r - %d - %f - %fd

%f

Which of the following statements is false? - Class, method, and variable names are identifiers. - An object has attributes that are implemented as instance variables and carried with it throughout its lifetime. - Every class declaration contains a keyword class followed immediately by the class's name. - Each class declaration that begins with the access modifier private must be stored in a file that has the same name as the class and ends with the .java filename extension.

Each class declaration that begins with the access modifier private must be stored in a file that has the same name as the class and ends with the .java filename extension.

Which of the following statements is false? - Instance variables can be declared anywhere inside a class. - A class normally contains one or more methods that manipulate the instance variables that belong to particular objects of the class. - Instance variables exist before methods are called on an object, while the methods are executing and after the methods complete execution. - By convention class names begin with an uppercase letter, and method and variable names begin with a lowercase letter.

Instance variables can be declared anywhere inside a class.

Which of the following statements is false? - Reference-type instance variables are initialized by default to the value void - A primitive-type variable cannot be used to invoke a method - A primitive-type variable does not refer to an object - A reference to an object is required to invoke an object's methods.

Reference-type instance variables are initialized by default to the value void. Actually, Reference-type instance variables are initialized by default to the value null.

Which of the following statements is true? - Each object (instance) of the class shares the class's instance variables. - Variables or methods declared with access modifier private are accessible only to methods of the class in which they're declared. - Most instance-variable declarations are preceded with the keyword public, which is an access modifier. - None of the above is true.

Variables or methods declared with access modifier private are accessible only to methods of the class in which they're declared.

A ________ of a class called MyClass is another class whose methods call the methods of MyClass. - caller - consumer - client - servant

client

Java requires a ________ call for every object that's created. - parameterized - destructor - constructor - parameterless

constructor

Floating-point literals are of type ________ by default. - real - float - decimal - double

double

A class that creates an object of another class, then calls the object's methods, is called a(n) ________ class. - caller - object-oriented - inherited - driver.

driver.

You can declare new classes as needed; this is one reason Java is known as a(n) ________ language. - portable - incremental - virtual - extensible

extensible

An import declaration is not required if you always refer to a class with its ________ name, which includes its package name and class name. - paired - fully qualified name - default package - compile-time

fully qualified name

When a method terminates, the values of its local variables are ________. - copied - saved - restored - lost

lost

You must call most methods other than ________ explicitly to tell them to perform their tasks. - private methods - main - public methods -static methods

main

Declaring instance variables ________ is known as data hiding or information hiding. - masked - secure - static - private

private

Types in Java are divided into two categories. The primitive types are boolean, byte, char, short, int, long, float and double. All other types are ________ types. - reference - declared - static - source

reference

A key part of enabling the JVM to locate and call method main to begin the app's execution is the ________ keyword, which indicates that main can be called without first creating an object of the class in which the method is declared. - private - stable - static - public

static

Reference-type variables (called references) store ________ in memory. - the size of an object - the value of an object -the location of an object -a copy of an object

the location of an object

If a class does not define constructors, the compiler provides a default constructor with no parameters, and the class's instance variables are initialized to ________. - false - their default values. - null - zero

their default values

The format specifier %.2f specifies that two digits of precision should be output ________ in the floating-point number. - to the right of the decimal point - to the left of the decimal point - centered - None of the above.

to the right of the decimal point

Each class you create becomes a new ________ that can be used to declare variables and create objects. - instance - library - package - type.

type.


Related study sets

Uppers Downers and all Arounders chapter 1/2

View Set

CISC 192 - MyProgrammingLab - Chapter 13

View Set

Chapter 2: Trends in HRM, HRIR 3021 (UMN-Peter Ronza)

View Set

The Legislative Branch: The Senate (Article 1,Section 3)

View Set

CH.7- Structuring System Process Requirements

View Set

Week 2- The Immune System Pharmacology ATI Questions (Exam 1)

View Set