Intro to Classes, Objects, Methods and Strings Flashcards
a) A ___ method is a special method that you can call without first creating an object of the class in which it is declared.
a) static
b) Keyword \_\_\_ in a class declaration is followed immediately by the class’s name.
b) class
c) Keyword ___ requests memory from the system to store an object, then calls the
corresponding class’s constructor to initialize the object.
c) new
d) Each parameter must specify both a(n) ___ and a(n) ___ .
d) type, name
e) By default, classes that are compiled in the same directory are considered to be in the
same package, known as the ___ .
e) default package
f) When each object of a class maintains its own copy of an attribute, the field that represents the attribute is also known as a(n) ___ .
f) instance variable
g) Java provides two primitive types for storing floating-point numbers in memory: ___ and ___ .
g) float, double
h) Variables of type double represent ___ floating-point numbers.
h) double-precision
i) Scanner method ___ returns a double value.
i) nextDouble
j) Keyword public is an access ___ .
j) modifier
k) Return type ___ indicates that a method will not return a value.
k) void
l) Scanner method ___ reads characters until it encounters a newline character, then returns those characters as a String.
l) nextLine
m) Class String is in package ___ .
m) java.lang
n) A(n) ___ is not required if you always refer to a class with its fully qualified class name.
n) import declaration
o) A(n) ___ is a number with a decimal point , such as 7.33, 0.0975 or 1000.12345.
o) floating-point number
p) Variables of type float represent ___ floating-point numbers.
p) single-precision
q) The format specifier ___ is used to output values of type float or double.
q) %f
r) Types in Java are divided into two categories— ___ types and ___ types.
r) primitive, reference
a) By convention, method names begin with an uppercase first letter, and all subsequent
words in the name begin with a capital first letter.
a) False. By convention, method names begin with a lowercase first letter and all subsequent words in the name begin with a capital first letter
b) An import declaration is not required when one class in a package uses another in the same package.
b) True
c) Empty parentheses following a method name in a method declaration indicate that the method does not require any parameters to perform its task.
c) True
d) Variables or methods declared with access modifier private are accessible only to methods of the class in which they’re declared.
d) True
e) A primitive-type variable can be used to invoke a method.
e) False. A primitive-type variable cannot be used to invoke a method—a reference to an object is required to invoke the object’s methods.
f) The compiler provides a default constructor with no parameters in any class that does not explicitly include a constructor.
f) True