1 review lectures. 2 the final exam paper duration: 2 hours reading: 15 minutes total marks: 65...
TRANSCRIPT
![Page 1: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/1.jpg)
1
Review Lectures
![Page 2: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/2.jpg)
2
The Final Exam Paper
Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5
![Page 3: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/3.jpg)
3
The Structure
Sections Questions Marks
Multiple Choice
25 25
Short Answer 6 15
Long Answer 3 25
Total 34 65
![Page 4: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/4.jpg)
4
Topics
Software Engineering (5% of 65)
![Page 5: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/5.jpg)
5
Topics (Cont’d)
Java and OOP (65% of 65) Concepts & Definitions Code fragments Writing a small program
![Page 6: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/6.jpg)
6
Topics (Cont’d)
UML and OOD (30% of 65) Concepts & Definitions Understanding Diagrams OOD Principles Design Patterns Design using UML
![Page 7: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/7.jpg)
7
Software Engineering - Introduction
Software Engineering is an engineering discipline which is concerned with all aspects of software production from the early stages of system requirements through to maintaining the system after is has gone into use.
![Page 8: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/8.jpg)
8
Software Process
Software Process defines the way to produce software. It includes Software life-cycle model Tools to use Individuals building software
Software life-cycle model defines how different phases of the life cycle are managed.
![Page 9: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/9.jpg)
9
Phases of Software Life-cycle
Requirements Specification (Analysis) Design Implementation Integration Maintenance Retirement
![Page 10: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/10.jpg)
10
Life-Cycle Models
Build-and-fix model Waterfall model Rapid prototyping model Incremental model Extreme programming Synchronize-and-stabilize model Spiral model Object-oriented life-cycle models Comparison of life-cycle models
![Page 11: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/11.jpg)
11
Abstract Data Type (ADT)
A structure that contains both data and the actions to be performed on that data.
Class is an implementation of an Abstract Data Type.
![Page 12: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/12.jpg)
12
Object Oriented DesignConcepts
![Page 13: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/13.jpg)
13
Class
Class is a set of attributes and operations that are performed on the attributes.
Account
accountNameaccountBalance
withdraw()deposit()determineBalance()
Student
nameagestudentId
getName()getId()
Circle
centreradius
area()circumference()
![Page 14: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/14.jpg)
14
Objects
An Object Oriented system is a collection of interacting Objects.
Object is an instance of a class.
![Page 15: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/15.jpg)
15
Classes/Objects
Student:John
:Jill
John and Jill are objects of class
Student
Circle:circleA
:circleB
circleA and circleB are
objects of classCircle
![Page 16: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/16.jpg)
16
Object Oriented Paradigm: Features
Encapsulation Data Abstraction Inheritance Polymorphism Persistence Delegation
![Page 17: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/17.jpg)
17
Java Review
![Page 18: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/18.jpg)
18
Hello World
// HelloWorld.java: Hello World programclass HelloWorld
{
public static void main(String args[])
{
System.out.println(“Hello World”);
}
}
![Page 19: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/19.jpg)
19
Program Processing
Compilation# javac HelloWorld.javaresults in HelloWorld.class
Execution# java HelloWorldHello World
![Page 20: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/20.jpg)
20
Basic Data Types Types
boolean either true of falsechar 16 bit Unicode 1.1 byte 8-bit integer (signed)short 16-bit integer (signed)int 32-bit integer (signed)long 64-bit integer (singed)float 32-bit floating point (IEEE 754-1985)double64-bit floating point (IEEE 754-1985)
String (class for manipulating strings) Java uses Unicode to represent characters
internally
![Page 21: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/21.jpg)
21
Control Flow
Control Flow Statements in JAVA while loop for loop do-while loop if-else statement switch statement
JAVA does not support a goto statement
![Page 22: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/22.jpg)
22
Classes
A class is a collection of fields (data) and methods (procedure or function) that operate on that data.
Circle
centreradius
circumference()area()
![Page 23: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/23.jpg)
23
Classes
A class is a collection of fields (data) and methods (procedure or function) that operate on that data.
The basic syntax for a class definition:
Bare bone class – no fields, no methods
public class Circle { // my circle class}
class ClassName [extends SuperClassName]{
[fields declaration] [methods declaration]
}
![Page 24: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/24.jpg)
24
Constructors
Constructor is a method that gets invoked at object creation time.
Constructors have the same name as the class. Constructors cannot return values. Constructors are normally used for initializing
objects. A class can have more than one constructor –
with different input arguments.
![Page 25: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/25.jpg)
25
Defining a Constructor Like any other method
Invoking: There is NO explicit invocation statement
needed: When the object creation statement is executed, the constructor method will be executed automatically.
public class ClassName {
// Data Fields…
// Constructor public ClassName() { // Method Body Statements initialising Data Fields }
//Methods to manipulate data fields}
![Page 26: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/26.jpg)
26
Method Overloading
Constructors all have the same name? In Java, methods are distinguished by:
name number of arguments type of position of arguments
Not method overriding (coming up), method overloading:
![Page 27: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/27.jpg)
27
Polymorphism
Allows a single method or operator associated with different meaning depending on the type of data passed to it. It can be realised through: Method Overloading Operator Overloading (Supported in C++, but
not in Java) Defining the same method with different
argument types (method overloading) - polymorphism.
The method body can have different logic depending on the date type of arguments.
![Page 28: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/28.jpg)
28
Scenario
A Program needs to find a maximum of two numbers or Strings. Write a separate function for each operation. In C:
int max_int(int a, int b) int max_string(char *s1, char *s2) max_int (10, 5) or max_string (“melbourne”,
“sydney”) In Java:
int max(int a, int b) int max(String s1, String s2) max(10, 5) or max(“melbourne”, “sydney”)
Which is better ? Readability and intuitive wise ?
![Page 29: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/29.jpg)
29
Data Hiding and Encapsulation
Java provides control over the visibility of variables and methods, encapsulation, safely sealing data within the capsule of the class
Prevents programmers from relying on details of class implementation, so you can update without worry
Keeps code elegant and clean (easier to maintain)
![Page 30: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/30.jpg)
30
Visibility
area
Circle
circumference
Center (x,y)Radius r
message
Construction time message
message
Circle
![Page 31: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/31.jpg)
31
Parameter passing
Method parameters which are objects are passed by reference.
Copy of the reference to the object is passed into method, original value unchanged.
![Page 32: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/32.jpg)
32
Delegation
Ability for a class to delegate its responsibilities to another class.
A way of making an object invoking services of other objects through containership.
![Page 33: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/33.jpg)
33
Inheritance
Ability to define a class as a subclass of another class.
Subclass inherits properties from the parent class.
Parent
Child
Inheritedcapability
![Page 34: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/34.jpg)
34
Subclassing
Subclasses created by the keyword extends:
Each GraphicCircle object is also a Circle!
public class GraphicCircle extends Circle { // automatically inherit all the variables and methods
// of Circle, so only need to put in the ‘new stuff’
Color outline, fill;public void draw(DrawWindow dw) { dw.drawCircle(x,y,r,outline,fill);
}}
![Page 35: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/35.jpg)
35
Abstract Classes
An Abstract class is a conceptual class.
An Abstract class cannot be instantiated – objects cannot be created.
Abstract classes provides a common root for a group of classes, nicely tied together in a package:
![Page 36: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/36.jpg)
36
Abstract Classes
package shapes;
public abstract class Shape { public abstract double area(); public abstract double circumference();
public void move() { // impementation }}
![Page 37: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/37.jpg)
37
Abstract Classes
public Circle extends Shape {protected double r;protected static final double PI =3.1415926535;public Circle() { r = 1.0; )public double area() { return PI * r * r; }
…}public Rectangle extend Shape {
protected double w, h;public Rectangle() { w = 0.0; h=0.0; }public double area() { return w * h; }
}
![Page 38: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/38.jpg)
38
Abstract Classes
Any class with an abstract method is automatically abstract
A class declared abstract, even with no abstract methods can not be instantiated
A subclass of an abstract class can be instantiated if it overrides each of the abstract methods, with an implementation for each
A subclass that does not implement all of the superclass abstract methods is itself abstract
![Page 39: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/39.jpg)
39
Interfaces
Interface is a conceptual entity similar to a Abstract class.
Can contain only constants (final variables) and abstract method (no implementation) - Different from Abstract classes.
Use when a number of classes share a common interface.
Each class should implement the interface.
![Page 40: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/40.jpg)
40
Interfaces: An informal way of realising multiple inheritance An interface is basically a kind of class—it
contains methods and variables, but they have to be only abstract classes and final fields/variables.
Therefore, it is the responsibility of the class that implements an interface to supply the code for methods.
A class can implement any number of interfaces, but cannot extend more than one class at a time.
Therefore, interfaces are considered as an informal way of realising multiple inheritance in Java.
![Page 41: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/41.jpg)
41
Interface - Example
speak()
Politician Priest
<<Interface>>Speaker
speak() speak()
Lecturer
speak()
![Page 42: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/42.jpg)
42
Interfaces Definition
Syntax (appears like abstract class):
Example:
interface InterfaceName {// Constant/Final Variable Declaration// Methods Declaration – only method body
}
interface Speaker {public void speak( );
}
![Page 43: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/43.jpg)
43
Error Handling
Any program can find itself in unusual circumstances – Error Conditions.
A “good” program should be able to
handle these conditions gracefully.
Java provides a mechanism to handle these error condition - exceptions
![Page 44: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/44.jpg)
44
Exceptions in Java
A method can signal an error condition by throwing an exception – throws
The calling method can transfer control to a exception handler by catching an exception - try, catch
Clean up can be done by - finally
![Page 45: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/45.jpg)
45
Common Java Exceptions
ArithmeticException ArrayIndexOutOfBoundException ArrayStoreException FileNotFoundException IOException – general I/O failure NullPointerException – referencing a null object OutOfMemoryException SecurityException – when applet tries to perform
an action not allowed by the browser’s security setting.
StackOverflowException StringIndexOutOfBoundException
![Page 46: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/46.jpg)
46
Exception Handling Mechanism
try Block
Statements that causesan exception
catch Block
Statements that handle the exception
Throwsexception
Object
![Page 47: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/47.jpg)
47
Syntax of Exception Handling Code
……try {
// statements
}catch( Exception-Type e){
// statements to process exception
}....
![Page 48: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/48.jpg)
48
Streams
Java Uses the concept of Streams to represent the ordered sequence of data, a common characteristic shared by all I/O devices.
Streams presents a uniform, easy to use, object oriented interface between the program and I/O devices.
A stream in Java is a path along which data flows (like a river or pipe along which water flows).
![Page 49: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/49.jpg)
49
I/O and Data Movement
The flow of data into a program (input) may come from different devices such as keyboard, mouse, memory, disk, network, or another program.
The flow of data out of a program (output) may go to the screen, printer, memory, disk, network, another program.
Both input and output share a certain common property such as unidirectional movement of data – a sequence of bytes and characters and support to the sequential access to the data.
![Page 50: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/50.jpg)
50
Stream Types
The concepts of sending data from one stream to another (like a pipe feeding into another pipe) has made streams powerful tool for file processing.
Connecting streams can also act as filters.
Streams are classified into two basic types:
Input Steam Output Stream
Source Program
Input Streamreads
SourceProgram
Output Stream
writes
![Page 51: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/51.jpg)
51
Java Stream Classes
Input/Output related classes are defined in java.io package.
Input/Output in Java is defined in terms of streams.
A stream is a sequence of data, of no particular length.
Java classes can be categorised into two groups based on the data type one which they operate: Byte streams Character Streams
![Page 52: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/52.jpg)
52
Classification of Java Stream Classes
Byte Streamclasses
Character Streamclasses
![Page 53: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/53.jpg)
53
Graphical User Interface (GUI) Applications
Abstract Windowing Toolkit (AWT)
Events HandlingApplets
![Page 54: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/54.jpg)
54
AWT - Abstract Windowing Toolkit
Single Windowing Interface on Multiple Platforms
Supports functions common to all window systems
Uses Underlying Native Window system AWT provides
GUI widgets Event Handling Containers for widgets Layout managers Graphic operations
![Page 55: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/55.jpg)
55
Building Graphical User Interfaces
import java.awt.*; Assemble the GUI
use GUI components, basic components (e.g., Button, TextField) containers (Frame, Panel)
set the positioning of the components use Layout Managers
Attach events
![Page 56: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/56.jpg)
56
A sample GUI program
import java.awt.*;public class MyGui {
public static void main(String args[] ) {
Frame f = new Frame ("My Frame");Button b = new Button("OK");TextField tf = new TextField("Programming in Java", 20);f.setLayout(new FlowLayout());f.add(b);f.add(tf);f.setSize(300, 300);f.setVisible(true);
}}
![Page 57: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/57.jpg)
57
outputOutput
![Page 58: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/58.jpg)
58
Sockets and Java Socket Classes
A socket is an endpoint of a two-way communication link between two programs running on the network.
A socket is bound to a port number so that the TCP layer can identify the application that data destined to be sent.
Java’s .net package provides two classes: Socket – for implementing a client ServerSocket – for implementing a server
![Page 59: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/59.jpg)
59
Java SocketsServerSocket(1234)
Socket(“128.250.25.158”, 1234)
Output/write stream
Input/read stream
It can be host_name like “mandroo.cs.mu.oz.au”
Client
Server
![Page 60: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/60.jpg)
60
A Multithreaded Program
Main Thread
Thread A Thread B Thread C
start startstart
Threads may switch or exchange data/results
![Page 61: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/61.jpg)
61
An example
class MyThread extends Thread { // the thread public void run() { System.out.println(" this thread is running ... "); }} // end class MyThread
class ThreadEx1 { // a program that utilizes the thread public static void main(String [] args ) {
MyThread t = new MyThread();// due to extending the Thread class (above)// I can call start(), and this will call// run(). start() is a method in class Thread.
t.start(); } // end main()} // end class ThreadEx1
![Page 62: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/62.jpg)
62
Life Cycle of Thread
new
runnable non-runnable
dead
wait()sleep()suspend()blocked
notify()resume()unblocked
start()
stop()
![Page 63: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/63.jpg)
63
Unified Modeling Language
![Page 64: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/64.jpg)
64
Software Development Process and Unified Modeling Language
(UML) A software development process is a set of phases that are
followed to bring a product or a system from conception to delivery.
In the Unified Process, there are four of these phases: Inception (Analysis phase)
identify the system we are going to develop, including what it contains and its business case.
UML: use-case diagrams Elaboration (Design phase):
perform detailed design and identify the foundation of system from “use case diagram”, which eventually lead to classes.
UML: classes, objects, class diagrams, sequence diagram, collaboration diagrams etc.
Construction (Implementation phase): write software using Java/C++
the actual building of the product from the design of the system. Transition (Rolling out phase): Deliver the system/product to
the users. Includes maintenance, upgrades, and so on until phasing out.
![Page 65: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/65.jpg)
65
UML– Diagrams – cont..
Structural
Class Diagram
Object Diagram
Component Diagram
Deployment Diagram
Behavioral
Use case Diagram
Sequence Diagram
Collaboration Diagram
Statechart Diagram
Activity Diagram
![Page 66: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/66.jpg)
66
Use Case Diagrams
Use Case diagrams show the various activities the users can perform on the system. System is something that performs a
function. They model the dynamic aspects of
the system. Provides a user’s perspective of the
system.
![Page 67: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/67.jpg)
67
Use Case Diagrams
A set of ACTORS : roles users can play in interacting with the system. An actor is used to represent something that users
our system. A set of USE CASES: each describes a possible
kind of interaction between an actor and the system. Uses cases are actions that a user takes on a
system A number of RELATIONSHIPS between these
entities (Actors and Use Cases). Relationships are simply illustrated with a line
connecting actors to use cases.
![Page 68: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/68.jpg)
68
Use Case Diagrams - Actors
An actor is a user of the system playing a particular role.
Actor is shown with a stick figure.
employee clientemployer
![Page 69: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/69.jpg)
69
Use Case Diagrams – Use Cases
Use case is a particular activity a user can do on the system.
Is represented by an ellipse. Following are two use cases for a
library system.
ReserveBorrow
![Page 70: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/70.jpg)
70
Use Case Diagram – Example1 (Library)
A Library System.
client employee
supervisor
library system
borrow
reserve
Order title
Fine payment
![Page 71: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/71.jpg)
71
Class Visibility
public level + protected level # private level -
- centreX:Int- centreY:Int=0
Circle
+ draw() # move(Int X, Int Y)
![Page 72: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/72.jpg)
72
Class Relationships
Classes can related to each other through different relationships: Association (delegation) Generalization (inheritance) Realization (interfaces) Dependency
![Page 73: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/73.jpg)
73
Association
Association describes a link, a link being a connection among objects between classes.
Association is shown by a solid line between classes.
![Page 74: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/74.jpg)
74
Association - Example
A Person works for a Company.
Person Companyemployee employ
erworks for
Association Name
Role
![Page 75: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/75.jpg)
75
Generalization (Inheritance)
Child class is a special case of the parent class
SuperClass
SubClass1 SubClass2
![Page 76: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/76.jpg)
76
Abstract Methods (Operations)
Shape
Circle Rectangle
draw()
draw() draw()
![Page 77: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/77.jpg)
77
Realization- Interface
<<interface>>TypeWriter
ctl()pageDown()
brandName numOfKeys
Keyboard
keyStroke()
Interface is a set of operation the class carries out
ctl()pageDown()
brandName numOfKeys
Keyboard
TypeWriter
OR
![Page 78: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/78.jpg)
78
Class Diagram Example
School Department
Student Course Instructor
1…*
*
member
* *
attends
* 1..*
teaches
1..*
1
1 1..*
has
1..*
1..*
assignedToofferedBy
![Page 79: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/79.jpg)
79
Sequence Diagram
Shows how objects communicate with each other over time.
The sequence diagram consists of OBJECTS, MESSAGES represented as solid-line arrows, and TIME represented as a vertical progression
![Page 80: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/80.jpg)
80
Sequence Diagram – Time & Messages
Messages are used to illustrate communication between different active objects of a sequence diagram.
:Name1 :Name2
Message Two
ActorMessage One
![Page 81: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/81.jpg)
81
Types of Messages
Synchronous (flow interrupt until the message has completed.
Asynchronous (don’t wait for response)
Flat – no distinction between sysn/async
Return – control flow has returned to the caller.
![Page 82: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/82.jpg)
82
Sequence Diagram – Compilation
:Compiler LinkerActor
Compile
FileSystem
Load Files
Save OBJ Files
Compile files
Link
Load OBJ files
Link OBJ files
Write EXE file
![Page 83: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/83.jpg)
83
Sequence Diagram – Enroll Student for subject successfully
u:URSDatabase
procCmd(cmd)parseCommand(cmd)
execute()
{transient}
a:AssgSubCmd<< create >>
AssgSubCmd(u,cmdA)
getStudent(id)
return stu
getSubject(subId)
return sub[if stu != NULL and sub != NULL]
stu:Student
addSubject(sub)
![Page 84: 1 Review Lectures. 2 The Final Exam Paper Duration: 2 hours Reading: 15 minutes Total marks: 65 Hurdle: 32.5](https://reader035.vdocuments.us/reader035/viewer/2022062618/5514648e5503462d4e8b5abe/html5/thumbnails/84.jpg)
84
Collaboration Diagram – Enroll Student in Subject Scenario
u:URSDatabase
{new}
a:AssgSubCmd
2:AddSubCmd(u,cmdA)
{transient}
<<local>>
3: execute()
3.1: stu: =getStudent(id)
<<self>>
1:parseCommand()
procCmd(cmd)
stu:Student
3.3: [stu !=NULL and sub!= NULL]:
addSubject(sub){parameter}
3.2: sub: = getSubject(subId)