Java Basics Flashcards
Where is a local variable defined?
In a method.
Where are instance members defined?
In the scope
T/F: An instance member can be a variable, constant or method
True
What is an instance member?
A member variable or method that belongs to a specific object instance.
T/F: Non-static members are instance members.
True
Does Java support multiple package statements?
No
Where does the package statement go in a file?
The first statement in the file.
What happens if no argument is passed to a main method?
The args parameter is then an array of Strings of length zero.
How do you declare a method where an instance of the class is not needed?
Use the static
keyword.
What is the correct parameter specification for the standard main method?
(String[ ] args)
or
(String args [ ] )
What does “class-level” mean in terms of access?
It means being accessible from anywhere (i.e. static as well as non-static methods) in the class (and from outside the class depending on their access modifier). This is done by using static methods.
What does “instance level” mean in terms of access?
It means accessible only from instance methods in the class. This is done with instance fields.
Which classes have access to a member with no modifier (default)?
Only members within the same package.
What is the visibility of local variables?
They are always accessible within the block in which they are declared.
Which modifiers can be applied to local variables?
Only final
.
They cannot be transient, volatile, static, public or private.