Chapter 1 - Declarations & Access Control Flashcards

0
Q

What are reference variables used for?

A

used to refer to or access an object.

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

What are the eight Primitive Data Types?

A
Bits       Bytes
Byte            8            1
Long          64           8
Int              32           4
String         
Boolean     vm dependent
Char          
Double       64           8
Float          32           4

*once declared the type cannot change but value can.

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

What is a class?

A

A template that describes the kinds of state and behavior that objects of its type support.

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

What is a object?

A

At runtime, when the JVM encounters the new keyword, it will use the appropriate class to make an object that is a instance of that class.

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

What is state?

A
Each object (instance of class) will have its own unique set of instance variables as defined in the class. 
Collectively, the values assigned to an objects instance variables make up the objects state.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is behavior?

A

(methods) when a programmer creates a class he/she creates methods for that class. Methods are where the classes logic is stored & where the real work gets done.

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

In Object Oriented Programming, what is inheritance?

A
It allows code defined in one class to be reused in another class. 
Ex: A superclass can have subclasses that have access to instance variables & methods & can override superclass methods to define more specific behavior. 
    Car superclass
      Ferrari subclass
        accelerated( )
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is interfaces?

A

They are methods from a superclass that a subclass must support. No logic for the method(s) is defined by the interface.

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

What must legal identifiers start with?

A

They must start with either a letter (a), currency character ($), or connecting character ( _ ) .

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

What must a legal identifier NOT start with?

A

It must not start with a digit. 1234…

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

How many public classes per source file?

A

One public class per source file.

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

What line must the package statement be on?

A

The first line.

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

Where do import statements go in a source file?

A

Import statements go between package statements and class declarations or must be the first lines in source code file.

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

When does the file name not have to match the name of a class?

A

When the source file has no public classes.

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

In:
Public static void main(String[ ] args)

What is main?

A

main( ) is the method that the Java Virtual Machine (JVM) uses to start execution of a Java program.

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

What are all the Access Modifiers and their definitions?

A

Default Access - is the same as package-level access but a class with default access can be seen only by classes within the same package.

Public Access - gives any class, method, or constructor access to any other class. If in a different package the class will need to be imported.

Protected Access - any variables, methods or constructors that are declared protected in a superclass can only be accessed by the subclasses in another package or any class within the package of the protected members’ class.

Private Access - any method, variable or constructor that is declared private can only be accessed within the declared class itself.

16
Q

What are all the nonAccess modifiers and their definitions?

A

Strictfp - a keyword used for modifying a class or method, but never a variable. (IEEE 754 standard)

Final - used as a class declaration, the class cannot be subclassed. No other class can ever extend (inherit from) a final class (no extensibility) .
*Used to guarantee that none of the methods in the class will ever be overwritten. 

Abstract - is used to never instantiate a class and therefore can never be extended.

17
Q

What is a abstract class?

A

It is a class that can only be extended (subclassed) and can never be instantiated.

*if the method is in a class, as opposed to a interface, then both the method and the class must be marked abstract or end with a semicolon.

18
Q

All variables defined in an interface must be what?

A

They must be public, static, and final.

*can only declare constants and no instance variables.

19
Q

Interface methods must not be what?

A

They must not be static.

20
Q

What can interface methods not be?

A

Interface methods are abstract and cannot be marked final, strictfp or native.

21
Q

What can an interface extend to?

A

A interface can only extend to another interface and cannot implement another interface.