cse 301 exam revision lecture

Post on 04-Jan-2016

45 Views

Category:

Documents

2 Downloads

Preview:

Click to see full reader

DESCRIPTION

CSE 301 Exam Revision Lecture. harry.erwin@sunderland.ac.uk james.malone@sunderland.ac.uk. Exam Format. Wednesday, 18 May 9:30-12:30 Seaburn Centre 14 Questions in total, Three sections; OO Programming (6 questions) OO Theory (4 questions) OO Practice (4 questions) - PowerPoint PPT Presentation

TRANSCRIPT

CSE 301Exam Revision Lecture

harry.erwin@sunderland.ac.uk

james.malone@sunderland.ac.uk

Exam Format

Wednesday, 18 May 9:30-12:30 Seaburn Centre 14 Questions in total, Three sections;

OO Programming (6 questions) OO Theory (4 questions) OO Practice (4 questions)

Answer TEN questions, with at least TWO from each section

Specific Advice

Know your Java syntax (ch 2-3, JiaN) Know how to use the Collection classes Know the basic patterns from the Pattern book Know how Java implements the concepts of OO

programming Know the concepts, principles and theory of OO Know how to use UML Know the risks and practices discussed in the text Understand the practices of XP

Basic Programming Topics Java Operators and Syntax Primitive Types (definitions and conversion) Reference Types (including the Object class) Access Modifiers Inner Classes Iterators Interfaces Constructors & Constructor Chaining

Intermediate and Advanced Programming Topics Input/Output Exception Handling Collection Classes Threads and Semaphores Swing and AWT Interfacing to the Internet, Serialization, and RMI Patterns Garbage Collection

Theory Topics

Definitions (Object, System, etc.) Interface Segregation Principle (ISP) Open-Closed Principle (OCP) Liskov Substitution Principle (LSP) Dependency Inversion Principle (DIP) Single-Responsibility Principle (SRP) Meyer’s Design By Contract Encapsulation, Inheritance, Subtype-

Polymorphism & Abstraction

Practice Topics

UML (eg Class diagrams, state charts, use cases, interaction diagrams, etc.)

Bad Software Design (when software smells) Design Patterns Modelling Classes Requirements Analysis Software Maintainability The Text in General Refactoring, TDD, XP

Questions from the Past

Name and describe the 8 primitive types Boolean, char, etc.

How is a type conversion done? When is it suitable (think data loss)? Wrapper classes

Describe the three categories of reference data types (that inherit from Object). Class instance, array, interface

Questions from the Past

Name the methods Object class provides toString(), clone(), getClass(), equals(), etc.

How is a class instantiated?Simple code:

public Balance currentBalance = new Balance();

What is a static method?Method not associated with an instance – but

rather at class level

Questions from the Past Describe 4 access modifiers

Remember table!

Accessible to: Public Protected Package Private

Defining Class Yes Yes Yes Yes

Class in same package Yes Yes Yes No

Subclass in different package Yes Yes No No

Non-sublcass different package Yes No No No

Questions from the Past

What is an inner class and how is it used?Class within a class

Static Member class Member class Local class Anonymous class

Questions from the Past

What is an iteratorAllow processing (step through) of each element

of a collection Sample code has been asked for!

Iterator myIterator= myCollection.iterator();while(myIterator.hasNext()){

Object myObject = myIterator.next();//do something with myObject – possibly

cast}

Questions from the Past What is an interface?

a collection of method definitions and constant values that define a behaviour

Replace multiple inheritance – more than one interface can be inherited.

Does not implement methods however What is a thread?

a separate stream of execution that takes place simultaneously with and independently of everything else – remember Thread class and Runnable interface

Questions from the Past What is an Exception? How is it dealt with in

Java? An Exception is an object created and thrown when

an exceptional circumstance (usually caused by an erroneous condition) occurs

Java – try, catch, throw, throws, finally Know the different types of Exceptions and how the

compiler enforces them.

Questions from the Past

What is a constructor? General description, code example might help

What is constructor chaining? A child object constructor always first needs to

construct its parent (which in turn calls its parent constructor.). Can also be ‘manufactured’ by enforcing other constructors to be called within the same or parent classes

Use of this, this(), super, and super()

Questions from the Past

Describe the Interface Segregation Principle (ISP)? Many client specific interfaces (narrow) are better than

one general purpose interface Fat interfaces lead to inadvertent coupling

Describe the Liskov Substitution Principle (LSP)? Subclasses should be suitable for their base classes The contract of the base class must be honoured by

the derived class

Questions from the Past

What is the Open-Closed Principle (OCP)?A module (class) should be open for

extension but closed for modification (originally by Bertrand Meyer).

Classes should be written so that they can be extended without requiring the classes to be modified.

To extend the behavior of a system (in response to a requested change) add new code, don’t modify existing code.

Questions from the Past Describe the Dependency Inversion Principle

(DIP) Depend upon abstractions. Do not depend upon

concrete implementations High level classes should not depend on low level

classes. Abstractions should not depend upon the details. If the high level abstractions depend on the low level

implementation details, then the dependency is inverted from what it should be.

Questions from the Past

Describe the Single-Responsibility Principle (SRP) A class should have only one reason to change A responsibility is “a reason for change.” The responsibilities of a class are axes of change. If it

has two responsibilities, they are coupled in the design, and so have to change together.

Questions from the Past

Meyer’s Design By Contract (later version)A contract consists of the preconditions a

method expects and the post-conditions it guarantees if it returns successfully.

If the method doesn’t return successfully, it throws an exception.

The contract is associated with the public methods of a class or interface.

Questions from the Past

Describe symptoms of bad software design (think when software smells) The system is rigid—hard to change because

everything has to change at once. The system is fragile—changes cause the system to

break in the strangest of places. The system is immobile—not reusable. The system is viscous—doing things right is hard. The system is needlessly complex. The system contains needless repetition. The system is opaque—hard to understand

Questions from the Past

Describe what is meant by encapsulationDiagram might help

Describe what is meant by inheritanceKeywords may also help (extends)

Describe what is meant by subtype-polymorphism The ability of an object or operator to refer to

instances of different classes at run time.

Questions from the Past How is abstraction achieved in Java?

Various ways – Abstract (keyword) classes, interfaces and inheritance

Describe a State chart / Use Case Diagram / Class Diagram / Interaction DiagramDiagram essential – key is to remember all

elements of the diagramKnow what they’re used for.

Questions from the Past

How might you gather and analyze requirements? Compare and contrast the approaches. Brainstorming, Observation etc.

Discuss and criticize the design principles the authors claim lead to maintainable software Design and conquer Increase cohesion where possible Reduce coupling where possible Keep the level of abstraction as high as possible Increase reusability where possible Reuse existing designs and code where possible Anticipate obsolescence Design for portability Design for testability Design defensively

General Advice

Read through whole paper once – work out which questions you answer best.

With 3 hours you have ~18 minutes per question

Good luck!!!

top related