Ch 1 - Java Building Blocks Flashcards
Java classes have two primary building blocks, what are they?
methods and fields
Methods and fields are the ? of the class
members
The full declaration of a method is called a what?
method signature
What are the three types of comments?
1. single line: // comment 2. multi line: /* * comment */ 3. java doc: /** * java doc comment */
You can put multiple classes in the same file, but at most ? can be public
one
The public class must match what?
…match the file name
true/false: a file can contain multiple classes where none of them is public
true
What is the lack of any access modifier for a class?
The default package private modifier
What does the default package private modifier indicate?
indicates the class can be accessed only by a class within the same package.
Give the class signature for the default package private modifer
class Defaultclass {}
How many access modifiers are there for classes?
two: public and default
To compile java code, the file must have an extension of what?
.java
The result of compiling is a bytecode file with a ? extension.
.class
What is the name of the one special package in java?
java.lang
Why is java.lang special?
it is special because it is automatically imported.
How many wildcards can you have in an import statement?
one
true/false: In an import, a wildcard matches class names
true
true/false: In an import, a wildcard matches sub package class names?
false
true/false: In an import, you can import methods
false
An object is a ? of a class.
an instance
the name of the ? matches the name of the class and there’s no return type.
constructor
Is this a constructor:
public void Chick() { }
no, because it has a return type
What happens if you do not provide a constructor?
The compiler will supply a do nothing default constructor for you.
What is an instance initializer block?
a code block outside of a method.
A code block is any code surrounded with what?
{ }
What is the order of initialization?
- static variables and static initializers in order
- instance variables and instance initializers in order
- constructors
Name the eight primitive types
byte short int long float double char boolean
When a number is present in the code, what is it called?
it is called a literal.
Why won’t this compile:
long max = 3123456789;
Need to include the “L” char at the end of the number.