Escolar Documentos
Profissional Documentos
Cultura Documentos
Exam Format
Topics Covered
String Processing
strings are immutable - what does this mean? how characters are stored in a string object
how string objects are created ? how string object are stored in memory
OOP Review
Creating static methods vs. non-static methods. Why client class methods are not static?
Inheritance
child class "inherits" stuff from parent class; you can change (override) methods or add
methods/variables
dynamic binding - what does this mean, how does it work, effects, etc.
Method overriding
casting parent/child classes (assigning reference of the parent class object of a child class)
How objects and object/reference variables are stored in memory, comparing objects with
== vs. .equals()
instanceof operator
Abstract Classes/Methods/Interfaces
Abstract methods
o methods with just a signature, no body
o often used in parent classes to include empty methods that only child classes will
implement
Abstract classes
o a class with at least one abstract method
o can contain attributes and methods that are implemented (have code)
Interfaces
o Why do we need them? How do define?
o How to use?
o Interface usage in GUI model
Intro to GUI
a.
b.
c.
d.
GUI Components
Layout Management. Using Layouts
Intro to Event Handling
Event Handling Practices
Wrapper classes - what they are, names, what they're for, etc.
Misc.
packages - what are they, why use them, how to create, naming conventions
Sample Questions
Coding
2.
firstName;
lastName;
phone;
address;
public Person() {}
public Person(String firstName, String lastName, String address,
String phone) {
setFirstName(firstName);
setLastName(lastName);
setAddress(address);
setPhone(phone);
}
public void setFirstName(String name) throws IllegalArgumentException
{
if (name.equals(""))
throw new IllegalArgumentException("Invalid first
name.");
else
firstName = name;
}
public String getFirstName() { return firstName; }
public void setLastName(String name) throws IllegalArgumentException
{
if (name.equals(""))
name.");
else
lastName = name;
}
public String getLastName() { return lastName; }
public void setAddress(String address) throws IllegalArgumentException
{
if (address.equals(""))
throw new IllegalArgumentException("Invalid address.");
else
this.address = address;
}
public String getAddress() { return address; }
public void setPhone(String phone) throws IllegalArgumentException
{
if (phone.equals(""))
throw new IllegalArgumentException("Invalid phone
number.");
else
this.phone = phone;
}
public String getPhone() { return phone; }
public String toString() {
return "Name: " + lastName + ", " + firstName + "\nPhone:
+ phone + "\nAddress: " + address;
}
"
Define a class called Student as a child class of Person with the following specifications:
String attributes for first name, last name, address, and phone number. These must not be
empty, or an exception is thrown.
A String attribute for student id, which is always exactly 9 digits. No letters are allowed.
If an id is invalid, an Exception with the message "Invalid student ID." is thrown.
A String attribute for program code, which is always exactly four characters. These
characters could be letters, digits, or any combination of letters and digits. If the program
code is invalid, throw an Exception with the message "Invalid program code".
A default constructor that contains no code. This allows the programmer to create an
empty object and set the values later.
A six-parameter constructor that takes the id, first name, last name, address, phone
number, and program code, and sets the values of those variables.
An equals() method that checks to see if two student objects are equal. Two Students are
equal if they have the same student ID.
a toString() method that returns a string representation of a student in the following form
(sample values used for the data):
ID: 123456789
Name: Schmoe, Joe
Phone: 905-845-9430
Address: 100 Main St.
Program: 3220