Mid+Term+Review+2015

Embed Size (px)

Citation preview

  • 7/21/2019 Mid+Term+Review+2015

    1/6

    Mid Term Review 2015 Winter

    Exam Format

    true/false and/or multiple choice questions

    short-answer questions, e.g.

    o define something, explain something, list things

    o fill in the blank, answer a question about a diagram/screen shot

    o write one or two statements to perform a certain task

    o write short coding statement

    1 coding problem (written, or using computer)

    Topics Covered

    String Processing

    strings are immutable - what does this mean? how characters are stored in a string obect

    how string obects are created ? how string obect are stored in memor!

    how concatenation affects a string obect ? string comparison" ## $s. equals()

    %tring class methods & 'haracter class methods

    'on$ersion methods used to con$ert $arious t!pes of data to %tring obects

    'omparing strings with .equals(), checking for null-string ()

    OOP Review

    * - creating classes, accessor/mutator methods, constructor methods, the this

    ke!word, to%tring() and equals() methods, etc.

    + class diagram, 'reating class in + format

    'reating static methods $s. non-static methods. h! client class methods are not static?

  • 7/21/2019 Mid+Term+Review+2015

    2/6

    %tatic methods and static $ariable, finall!, wh! do we need them?

    n!eritance

    hat is inheritance, how does it work? h! use inheritance?

    erms" *arent class/child class& super class/sub class& base/deri$ed class

    how to code a child class - extends ke!word

    he super ke!word - e.g. super.something or super()

    child class inherits stuff from parent class& !ou can change (o$erride) methods or add

    methods/$ariables

    d!namic binding - what does this mean, how does it work, effects, etc.

    %imple/%ingle-inheritance $s. multiple-inheritance - which does 0a$a support?

    ethod o$erriding

    casting parent/child classes (assigning reference of the parent class obect of a child class)

    Misc" OOP Concepts

    'lass design - t!pes of class relationships" composition, aggregation, inheritance&

    characteristics of good program or class design, etc. (see *ower*oint from this lesson)

    + class relationship diagram, classes relationship in + format

    bect class - top of the hierarch!. hat is inside bect class?

    to%tring(), equals() - inherited from obect

    implicit call to to%tring() method e.g. %!stem.out.println(obectariable)&

    2ow obects and obect/reference $ariables are stored in memor!, comparing obects with

    ## $s. .equals()

    instanceof operator

    *ol!morphism - what does this mean? 3!namic binding ?

  • 7/21/2019 Mid+Term+Review+2015

    3/6

    ethod o$erloading $s. method o$erriding - what4s the difference? 5xamples6

    #$stract C%asses&Met!ods&nter'aces

    2ow do !ou define a class/method as abstract?

    hat are abstract classes/methods& wh! do we need them?

    7bstract methods

    o methods with ust a signature, no bod!

    o often used in parent classes to include empt! methods that onl! child classes will

    implement

    7bstract classes

    o a class with at least one abstract method

    o can contain attributes and methods that are implemented (ha$e code)

    8nterfaces

    o h! do we need them? 2ow do define?

    o 2ow to use?

    o 8nterface usage in 9+8 model

    ntro to ()

    a. 9+8 'omponents

    b. a!out anagement. +sing a!outsc. 8ntro to 5$ent 2andling

    d. 5$ent 2andling *ractices

    Primitive *ata O$+ects

    rapper classes - what the! are, names, what the!4re for, etc.

    he hierarch! of the wrapper classes - child/parent, :umber class, etc.

    +seful methods and constants e.g. 7;

  • 7/21/2019 Mid+Term+Review+2015

    4/6

    rapper 'lasses ? =or example, >oolean class -- parse>oolean() and booleanalue()

    methods and how the! work

    Misc"

    a$adoc - con$entions, tags, what the!4re for, etc.

    packages - what are the!, wh! use them, how to create, naming con$entions

    Samp%e ,-estions

    Coding

    1" #n. o' programs 'rom /ome #ssignments& Practic-m & a$ co-%d $e considered as

    an examp%e"

    . 5xample " 7 class called *erson is defined as follows"

    public class Person

    {

    private String firstName;

    private String lastName;

    private String phone;

    private String address;

    public Person() {}

    public Person(String firstName, String lastName, String address,

    String phone) {

    setFirstName(firstName);

    setLastName(lastName);

    setddress(address);

    setPhone(phone);

    }

    public void setFirstName(String name) thro!s "llegalrgument#$ception

    {

    if (name%e&uals(''))

    thro! ne! "llegalrgument#$ception('"nvalid first

    name%');

    else

    firstName name;

    }

    public String getFirstName() { return firstName; }

    public void setLastName(String name) thro!s "llegalrgument#$ception

    {

    if (name%e&uals(''))

  • 7/21/2019 Mid+Term+Review+2015

    5/6

    thro! ne! "llegalrgument#$ception('"nvalid last

    name%');

    else

    lastName name;

    }

    public String getLastName() { return lastName; }

    public void setddress(String address) thro!s "llegalrgument#$ception

    {

    if (address%e&uals(''))

    thro! ne! "llegalrgument#$ception('"nvalid address%');

    else

    this%address address;

    }

    public String getddress() { return address; }

    public void setPhone(String phone) thro!s "llegalrgument#$ception

    {

    if (phone%e&uals(''))

    thro! ne! "llegalrgument#$ception('"nvalid phone

    number%');else

    this%phone phone;

    }

    public String getPhone() { return phone; }

    public String toString() {

    return 'Name ' * lastName * ', ' * firstName * '+nPhone '

    * phone * '+nddress ' * address;

    }

    }

    3efine a class called %tudent as a child class of *erson with the following specifications"

    %tring attributes for first name, last name, address, and phone number. hese must not be

    empt!, or an exception is thrown.

    7 %tring attribute for student id, which is alwa!s exactl! @ digits. :o letters are allowed.

    8f an id is in$alid, an 5xception with the message 8n$alid student 83. is thrown.

    7 %tring attribute for program code, which is alwa!s exactl! four characters. hese

    characters could be letters, digits, or an! combination of letters and digits. 8f the program

    code is in$alid, throw an 5xception with the message 8n$alid program code.

    7 default constructor that contains no code. his allows the programmer to create an

    empt! obect and set the $alues later.

    7 six-parameter constructor that takes the id, first name, last name, address, phone

    number, and program code, and sets the $alues of those $ariables.

  • 7/21/2019 Mid+Term+Review+2015

    6/6

    7ccessor/mutator methods for the attributes.

    7n equals() method that checks to see if two student obects are equal. wo %tudents are

    equal if the! ha$e the same student 83.

    a to%tring() method that returns a string representation of a student in the following form(sample $alues used for the data)"

    " -./012345

    Name Schmoe, 6oe

    Phone 5718401850/7

    ddress -77 9ain St%

    Program /..7

    }