Update 2025-2026
What are the 3 ways to use square brackets with an array name? - Answers 1. Used to create an
array type variable
2. Used with an integer value to create a new array
3. Used to name an indexed variable
What happens when an array index is out of bounds? - Answers Your program will end with a
run time error message
What are the 3 ways of initializing an array? - Answers 1. In enclosed braces
2. Individual initialization of each indexed variable
3. Using a for loop
What happens if you do not initialize the elements in an array? - Answers They will be
automatically initialized to default values for the base type
What are the default values for:
1. Numeric Types
2. Char types
3. Boolean types
4. Class types - Answers 1. The primitive value of 0 of their type
2. (char)0
3. False
4. Null
What is a vararg specification? - Answers It specifies that the method can accept any number of
arguments
ex. type...Array_Name
must be the last item on the parameter list
,What is an enumerated type - Answers A simple type consisting of a short list of named values
What is a ragged array? - Answers An array with different rows that have different columns
What are the 3 different uses for the keyword final? - Answers 1. Used to turn off late binding
2. Used to prevent inheritance and having derived classes
3. Used to prevent any changes to methods or variables
When an exception is thrown inside a method using the throw statement, but not caught, what
exactly needs to be done with the method definition in order for it to be syntactically correct? -
Answers Include a throws clause
What is the difference between overloading and overriding a method name? - Answers
Overloading - methods that have the same name but different number of parameters or
different parameter locations
Overriding - changing the meaning of the method in a derived class compared to the definition
in the base class
Can an interface ever contain method bodies? - Answers No
Is it okay if a class definition implements two interfaces, each of which have the same definition
for the constant pi - Answers No - if a class implements several interfaces, each constant must
be defined in only one interface
What is the difference between the comparable and comparator classes? - Answers
Implementing the comparable interface on a class defines the default sort order for objects of
that class; implementing the comparator interface on a class allows you to create an alternative
sort order for that class
What does the validate method do? - Answers It guarantees the visual representation of a
content pane is up to date
What is the rule for changing the access permission of an overridden method? - Answers They
can only be changed to be more accessible
What is a covariant return type? - Answers Changing the return type of a method to a
descendent type
Can you change the return type of a method when overriding? - Answers No, only if you are
changing the return type to a descendent type
What does the super constructor do? - Answers It allows you to invoke a constructor of the base
, class from within a derived class
What are the 4 restrictions of using the super constructor? - Answers 1. You cannot use an
instance variable as an argument
2. Must be the first action taken in a constructor definition
3. Cannot use the name of the constructor
4. If a constructor definition of a derived class does not include an invocation of a constructor
for the base class, then the no-argument constructor of the base class is invoked automatically
as the first action of the derived class constructor
Can inherited private instance variables be mentioned by name in a derived class? - Answers No.
You must use public accessor or mutator methods defined in the base class
Can inherited private methods be accessed in the derived class? - Answers No. They cannot be
accessed indirectly with other methods. They may be indirectly available if the method is used
in the definition of a public method of the base class
What are the two classifications of instance variables and methods that allow them to be
accessed by name in a derived class? - Answers 1. Protected access (always gives access)
2. Package access (gives access if the derived class is in the same package as the base class)
Where can a protected method/instance variable be accessed from by name? (3) - Answers 1.
Its own class
2. Any class derived from it
3. Any class in the same package
Why is the protected classification considered weaker than the package access classification? -
Answers It allows direct access to any programmer willing to go through the bother of defining
a suitable derived class
When is it best to use package access classification? - Answers When you have a package of
cooperating classes that act as a single encapsulated unit
What is the default package? How does this relate to access classifications? - Answers It is the
unnamed package of a class that does not belong to another package
Will have package access to any of the classes that are not in a defined class
Can a derived class object access variables and methods of a protected base class object? -
Answers No, it can only use instance variables and methods for the object of its own class