CP213 FINAL EXAM QUESTIONS AND
CORRECT ANSWERS. VERIFIED
2025/2026.
ArrayList - ANS Dynamic array
ArrayList<String> namelist;
nameList = new ArrayList<String>();
Has instance methods:
Add
Get(index)
Size
Varargs (variable argument) - ANS Allows a method to accept zero or multiple arguments
returnTypr MethodName (dataType ... variableName)
... must be included
Can only be one in the argument
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
, Must be the last argument
Inheritance - ANS Using this technique, a very general form of a class is first defined and
complied, and then more specialized versions of the class are defined by adding instance
variables and methods. The new specialized classes automatically have all the instance variables
and methods that the base case has.
Allows code to be reused without copying it into the definition of the derived classes
public class HourlyEmployee extends Employee{...}
Override - ANS Derived classes can change or "override" inherited methods from the base
class to provide their version of the method
@Override
public double area (double...dimensions) {
}
Overloading - ANS When a method in a derived class has a different signature from the
method in the base class, that is overloading
It still inherits the original method from the base class as well
Final modifiers - ANS If it is placed before the definition of a method, that method may not
be redefined in a derived class, and if it is placed before a class, that class may not be used as a
base class to derive other classes
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
CORRECT ANSWERS. VERIFIED
2025/2026.
ArrayList - ANS Dynamic array
ArrayList<String> namelist;
nameList = new ArrayList<String>();
Has instance methods:
Add
Get(index)
Size
Varargs (variable argument) - ANS Allows a method to accept zero or multiple arguments
returnTypr MethodName (dataType ... variableName)
... must be included
Can only be one in the argument
1 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.
, Must be the last argument
Inheritance - ANS Using this technique, a very general form of a class is first defined and
complied, and then more specialized versions of the class are defined by adding instance
variables and methods. The new specialized classes automatically have all the instance variables
and methods that the base case has.
Allows code to be reused without copying it into the definition of the derived classes
public class HourlyEmployee extends Employee{...}
Override - ANS Derived classes can change or "override" inherited methods from the base
class to provide their version of the method
@Override
public double area (double...dimensions) {
}
Overloading - ANS When a method in a derived class has a different signature from the
method in the base class, that is overloading
It still inherits the original method from the base class as well
Final modifiers - ANS If it is placed before the definition of a method, that method may not
be redefined in a derived class, and if it is placed before a class, that class may not be used as a
base class to derive other classes
2 @COPYRIGHT 2025/2026 ALLRIGHTS RESERVED.