Use LEFT and RIGHT arrow keys to navigate between flashcards;
Use UP and DOWN arrow keys to flip the card;
H to show hint;
A reads text to speech;
17 Cards in this Set
- Front
- Back
What is the location of package statement? |
If present, package statement should always be the first statement in the class file. Otherwise, compilation error. |
|
How many classes can be defined in a .java file? |
A java file can define many classes and interfaces, however, only one public class/interface can be present among those |
|
What's the rule for defining public classes in a java file? |
A public class must be defined in a java file with the same name, and it must be the only public class/interface in that file. |
|
Can you run a java file that doesn't have a main method? |
No, it will result in error. |
|
Is package name considered an identifier? |
No, so when asked if com.java.lang is a valid java identifier, say no, because it's not - you cannot use periods in java identifiers. |
|
Can you use reserved java keywords as identifiers? |
Yes, if their spelling has been altered, for example if you start with capital letter. Remember Java is case-sensitive. Example Abstract with capital A. |
|
Can you start a variable name with a digit? |
No, only ASCII Latin letters, dollar sign and underscore |
|
What is an instance initializer? |
It's a code block outside a method (code block is separated with braces). |
|
What is a field initializer? |
Code that initializes the class fields (variables) to values. |
|
What is the order of running initializers when creating a new object? |
First field initializers, then instance initializers in the sequence they appear in the file. |
|
When is the constructor run in relation to initializers? |
After fields and instance initializers are run. |
|
Can you reference a field variable in an initializer before it is defined (a few lines below)? |
No, the code won't compile if you try to use a field variable in an initializer and that variabe is defined below the initializer code. |
|
Can you use compound operator (+=) with variables that haven't been initialized (on the same line as declaration)?
|
No, this has to happen on separate lines. Otherwise, compile error.
|
|
Does Java code compiled on Windows need to be re-compiled for Unix?
|
No, because Java bytecode is platform independent.
|
|
What package contains classes for Date and Time in Java 8?
|
java.time
|
|
Can you leave a final variable un-initialized?
|
No, this will throw a compiler error.
|
|
Is a variable defined within an if/else block visible to outside code?
|
No, it's local to that block only.
|