1.Declarations and Access Control Flashcards Preview

JAVA OCA7 > 1.Declarations and Access Control > Flashcards

Flashcards in 1.Declarations and Access Control Deck (81)
Loading flashcards...
1

Identifiers can begin with...

a letter, an underscore, or a currency character

2

After the first character...

identifiers can also include digits

3

Identifier length can be...

Identifiers can be of any length

4

You can compile and execute Java programs using the command-line programs...

java and javac. Both programs support a variety of
command-line options.

5

The only versions of main() methods with special powers are those
versions with method signatures equivalent to...

public static void main(String[] args)

6

can main be overloaded?

Yes

7

what does an import statement is good for?

only job is to save keystrokes

8

why do we use asterisk (*) in imports?

to search through the contents of a single
package

9

what is the syntax for static imports?

import static….

10

how many public classes can a source file have?

only one

11

If the source file contains a public class, what can be the class names?

the filename must match the
public class name

12

How many package statements can a file have?

Only one

13

Where is the correct place for package statement

the first line in a source file

14

Where is the correct place for import statement

after the package and before the class declaration. If there is no package statement, import statements must be the first (noncomment) statements in the source file.

15

how the package and import statements apply to classes in a file

to all classes in the file

16

how many nonpublic classes can a file have?

more than one

17

How can we name nonpublic classes?

no public classes have no naming restrictions

18

What are class access modifiers?

public, protected, and private

19

How many access levels are there?

public, protected, default, and private

20

Which accesses a class can have?

public or default access

21

A class with default access can be seen..

only by classes within the same
package.

22

A class with public access can be seen by...

all classes from all packages.

23

Class visibility revolves around whether code in one class can...

❑ Create an instance of another class
❑ Extend (or subclass) another class
❑ Access methods and variables of another class

24

Nonaccess modifiers for classes are...

final, abstract, or strictfp

25

Can a class be both final and abstract?

No

26

What does it mean for a class to have "final" as modifier?

A final class cannot be subclassed.

27

What does it mean for a class to have "abstract" as modifier?

An abstract class cannot be instantiated

28

Can a non abstract class have an abstract method inside?

No. A single abstract method in a class means the whole class must be abstract.

29

Can an abstract class have non abstract methods?

Yes, an abstract class can have both abstract and nonabstract methods.

30

When should the abstract methods be implemented?

The first concrete class to extend an abstract class must implement all of its abstract methods