CH. 3 INTRO TO CLASSES, OBJECTS, METHODS, STRINGS Flashcards

1
Q

Each class declaration that begins with keyword _____

must be stored in a file that has exactly the same name as the class and ends with the .java file name extension.

A

public

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Keyword _____ in a class declaration is followed immediately by the class’s name.

A

class

Ex: pulbic class Welcome1

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Keyword ____ requests memory from teh system to store an object, then calls the corresponding class’s constructor to initialize the object

A

new

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

EACH PARAMETER MUST SPECIFY BOTH

A ____ AND A ____

A

TYPE AND A NAME

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

BY DEFAULT, CLASSES THAT ARE COMPILED IN THE SAME DIRECTORY ARE CONSIDERED TO BE IN THE SAME PACKAGE, KNOWN AS THE _____

A

DEFAULT PACKAGE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

WHEN EACH OBJECT OF A CLASS MAINTAINS ITS OWN COPY OF AN ATTRIBUTE, THE FIELD THAT REPRESENTS THE ATTRIBUTE IS ALSO KNOWN AS A ___________

A

INSTANCE VARIABLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

JAVA PROVIDES TWO PRIMITIVE TYPES FOR STORING FLOATING POINT NUMBERS IN MEMORY:

______ AND _____

A

FLOAT AND DOUBLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

VARIABLES OF TYPE DOUBLE REPRESENT ______

FLOATING POINT NUMBERS

A

DOUBLE PRECISION

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

SCANNER METHOD ____ RETURNS A DOUBLE VALUE

A

nextDOUBLE

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

KEYWORD PUBLIC IS AN ACCESS ______.

A

MODIFIER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

RETURN TYPE _____ INDICATES THAT A METHOD WILL NOT RETURN A VALUE

A

VOID

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

SCANNER METHOD _______

READS CHARACTERS UNTIL IT ENCOUNTERS A NEWLINE CHARACTER, THEN RETURNS THOSE CHARACTERS AS A STRING

A

nextLine

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

CLASS STRING IS IN PACKAGE ______

A

java.lang

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

A(n) ______ is not required if you always refer to a class with its fully qualified class name.

A

import declaration

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

A ______ IS A NUMBER WITH A DECIMAL POINT, SUCH AS 7.33, 0.9775 OR 1000.0123

A

FLOATING POINT NUMBER

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

VARIABLE of type float represent _____ floating point numbers

A

SINGLE PRECISION

17
Q

The format specifier _____ is used to output values of type float or double

A

%f

18
Q

Types in Java are divided into two categories

______ types and ______ types

A

PRIMITIVE AND PARAMETER

Primitive Types: Whole Number Types ( byte, short, int, long) Deciamal Types (float and double)

19
Q

By convention, method names begin with an uppercase first letter, and all subsequent words in the name begin with a capital first letter.

True or False

A

FALSE

By convention, method names begin with lowercase first letter and all subsequent words in the name begin with a capital first letter

20
Q

An import declaration is not required when one class in a package uses another in the same package

A

TRUE

21
Q

Empty parentheses following a method name in a method declaration indicate that the method does NOT require any parameters to perform a task

A

TRUE

22
Q

Variables or methods declared with access modifier “private” are accessible only to methods of the class in which they’re declared

A

TRUE

23
Q

A primitive-type variable can be used to invoke a method.

A

FALSE

A primitive-type variable cannot be used to invoke a method - a reference to an object is requried to invoke the objects methods

24
Q

Variable declared in the body of a particular method are known as instance variables and can be used in all methods of the class.

A

FALSE

Such variables are called “local vairables” and can used only in the method in which they are declared in.

25
Q

Every method’s body is delimited by left and right braces ( { } )

A

TRUE

26
Q

Primitive-type local variables are initialized by default.

A

FALSE

Primitive type instance variables are initialized by default

27
Q

Reference-type instance variables are initialized by default to the valule null.

A

TRUE

28
Q

Any class that contains

 ***public static void*** main ( String [] args )

can be used to execute an application

A

TRUE

29
Q

The number of arguments in the method call must match the number of parameters in the method declaration’s parameter list.

A

TRUE

30
Q

Floating-point values that appear in source code are known as floating-point literals and type float by default

A

FALSE

Such literals are of type double by default

31
Q

What is the difference between local variable and a field

A

Local variable is declared in the body of a method and can be used only from the point at which it is declared through the end of the method declaration.

A field is declared in a class, but not in the body of any of the class’s methods. Are accessible to all methods of the class.

32
Q

Explain the purpose of a method parameter.

What is the difference between a parameter and an argument?

A

Parameter represents additional info that a method requries to perform a task, Each parameter rquired by a mehtod is specified in the method’s declaration.

Argument is the actual value for teh method parameter.

33
Q
A