SlideShare a Scribd company logo
1 of 36
Download to read offline
Object Oriented Programming
                  1




LECTURER: NURHANNA AZIZ
ROOM: 3206
EMAIL: NURHANNA@KUIS.EDU.MY
HP: 0192223454
Prerequisites
                        2

Must have taken “Introduction to Programming” /
“Fundamental of Programming” subject
Basic understanding of programming (variables,
control flow, branch condition, simple array etc)
Student must be able to write a simple program
Recommended Books
                         3

Deitel & Deitel
 Java How to Program. 2007. Pearson International
 Edition.
Dennis Liang
 Java Object Oriented Programming. 2009.
 Thompson Learning
C. Thomas Wu.
 An introduction to Object Oriented Programming
 with Java. 2004. McGrawHill.
Syllabus
                      4

Object Oriented Programming
Method
Encapsulation
Inheritance
Polymorphism
Exceptions
Java Applet
Building Java GUIs
GUI Event Handling
GUI-based applications
Course Evaluation
                    5

Mid term Test     20%
Project           20%
Lab Assessments    15%
Attendance           5%
Final Exam        40%
Teaching Outcomes
                         6

By the end of this module, student should be :
 Familiar with programming concept within JAVA
 Able to carry out design and development of complex
 element such as user interfaces
Learning Outcomes
                         7

An appreciation of the complexities of large
programs, and the use of classes and inheritance to
manage this complexity
 The ability to design a collection of classes to
implement a large program
 An appreciation of good programming style (clarity,
elegance)
How to pass the subject?
                   8


Continuous Assessment (Coursework)
60%
Final Exam 40%

For DTCO 3023 – 50% overall to pass
For DTCO 3103 & DTCO 3113 – 40%
overall to pass

Attend the lectures
Do assignment, exercise
Do all the practical(lab) as best as you can.
Project Presentation
Attendance
                              9

Student will be bared from sitting for final exam if
 Not attend for lectures & lab – 3 times continuously; or
 Have 30% and more absent record
Revision
   10
Sample of Java Application Program
                    11




                         VIEW SOURCE
      RUN PROGRAM           CODE
Source Code
     12




          Name of the class / programs
                  The “main” method
Why Java?
                       13

“Write once, Run Anywhere”
Security
Network-centric Programming
Dynamic, Extensible Program
Internationalization
Performance
Programmer efficiency and time-to-Market
Java: Names & Reserved Names
                                     14

  Legal name (variables, method, fields,
  parameter,class, interface or package)
        Start with:
          Letter/dollar sign($)/ underscore (_)/ digits(0-9)
  Reserved names
abstract      char         else           goto         long        public

assert        class        extends        if           native      return

boolean       const        false          implements   new         short

break         continue     final          import       null        static

byte          default      finally        instanceof   package     strictfp

case          do           float          int          private     super

catch         double       for            interface    protected   switch
Java Naming Conventions
                    15



Names of variables, fields, methods:
 Begin with lowercase letter
 shape, myShape
Name of classes and interfaces:
 Begin with UPPERCASE letter
 Cube, ColorCube
16


Named constants:
   Written fully in UPPERCASE
   Separated by underscore (_)
   CENTER, MAX_VALUE, MIN_VALUE
If name is composed of several words:
   First word begins with lowercase, first letter of
   second word begins with UPPERCASE, the rest
   back to lowercase
   setLayout,addPatientName
Comments
                         17


Have no effect on the execution of the program
2 forms:
 one-line comments
   E.g.
     Class Comment {
     // This is one-line comment, its extends to the
     end of line }

 delimited comments
   E.g.
     Class Comment {
     /* This is a delimited comment,
            extending over several lines
        */
Types
                            18


Primitive type
 E.g.
   boolean,char,byte,short, int, long,float,double
Reference type
 Class type defined/ interface type defined
Array type
 In form [ ]
Variables
                          19


Syntax
 <Variable-modifier>< type>< variables_name>;
E.g.
 public static void main (String[] args){
   int a, b,c;
   int x=1, y=2,z=3;
   int myDivide=z/x;
   double PI=3.1415;
   boolean isFound=false;
 }
Declaring Variables
                  20




int x;          // Declare x to be an
                // integer variable;
double radius; // Declare radius to
               // be a double variable;
char a;         // Declare a to be a
                // character variable;
Assignment Statements
            21




x = 1;           // Assign 1 to x;

radius = 1.0;    // Assign 1.0 to
a = 'A';         // Assign 'A' to a;
Declaring and Initializing in One Step
                22




     int x = 1;
     double d = 1.4;
Constants
            23



final datatype CONSTANTNAME = VALUE;

final double PI = 3.14159;
final int SIZE = 3;
The String Type
                        24


     E.g.: String message = "Welcome to Java";
String Concatenation
  // Three strings are concatenated
  String message = "Welcome " + "to " + "Java";

  // String Chapter is concatenated with number 2
  String s = "Chapter" + 2; // s becomes Chapter2

  // String Supplement is concatenated with character B
  String s1 = "Supplement" + 'B'; // s1 becomes
  SupplementB
Programming Errors
                   25

Syntax Errors
 Detected by the compiler
Runtime Errors
 Causes the program to abort
Logic Errors
 Produces incorrect result
Converting Strings to Integers
                         26




 use the static parseInt method in the Integer class
as follows:

     int intValue =
     Integer.parseInt(intString);

where intString is a numeric string such as “123”.
Converting Strings to Doubles
                        27


 use the static parseDouble method in the Double
class as follows:

double doubleValue
=Double.parseDouble(doubleString);

where doubleString is a numeric string such as
“123.45”.
28
                The Two-way if Statement
if (boolean-expression) {
  statement(s)-for-the-true-case;
}
else {
  statement(s)-for-the-false-case;
}


                            true                 false
                                     Boolean
                                    Expression

   Statement(s) for the true case                Statement(s) for the false case
if...else Example
                   29


if (radius >= 0) {
  area = radius * radius * 3.14159;

 System.out.println("The area for the “
   + “circle of radius " + radius +
   " is " + area);
}
else {
  System.out.println("Negative input");
}
Common Errors
                             30


 Adding a semicolon at the end of an if clause is a common
mistake.
  if (radius >= 0);
  {
    area = radius*radius*PI;
    System.out.println(
      "The area for the circle of
  radius " +
      radius + " is " + area);
  }
switch Statements
switch (status) { 31
  case 0: compute taxes for single filers;
       break;
  case 1: compute taxes for married file jointly;
       break;
  case 2: compute taxes for married file separately;
       break;
  case 3: compute taxes for head of household;
       break;
  default: System.out.println("Errors: invalid status");
       System.exit(0);
}
32
        while Loops

int count = 0;
while (count < 100) {
  System.out.println("Welcome to Java");
  count++;
}
while Loop Flow Chart
                                            33
                                                 int count = 0;
while (loop-continuation-
condition) {                                     while (count < 100) {

    // loop-body;                                    System.out.println("Welcome to Java!");
                                                     count++;
    Statement(s);
                                                 }
}
                                                                  count = 0;



                       Loop
                                    false                                          false
                    Continuation                                (count < 100)?
                     Condition?

                      true                                         true
                     Statement(s)                    System.out.println("Welcome to Java!");
                     (loop body)                     count++;




                        (A)                                           (B)
do-while Loop
                       34




                                   Statement(s)
                                   (loop body)


                            true      Loop
                                   Continuation
do {                                Condition?
  // Loop body;                             false
  Statement(s);
} while (loop-continuation-condition);
for Loops
                                           35   int i;
for (initial-action;
  loop-continuation-                            for (i = 0; i < 100;
  condition; action-                              i++) {
  after-each-iteration) {                         System.out.println(
   // loop body;                                     "Welcome to
   Statement(s);
}                                                 Java!");
                                                }

                Initial-Action                             i=0


                    Loop
                                   false                                   false
                 Continuation                            (i < 100)?
                  Condition?
                  true                                   true
                 Statement(s)                       System.out.println(
                 (loop body)                         "Welcome to Java");

          Action-After-Each-Iteration                       i++




                     (A)                                    (B)
Review Questions
                     36



Problems:
 1. Wahid just bought himself a set of home
 theatre. Declare a variables of TV of type
 String, speakers of type int, price of type
 double and goodCondition of type boolean.

 2. Amir had 5 history books. Declare an
 array of book he had.

More Related Content

What's hot

FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3 rohassanie
 
05 -working_with_the_preproce
05  -working_with_the_preproce05  -working_with_the_preproce
05 -working_with_the_preproceHector Garzo
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handlingIntro C# Book
 
Virtual function
Virtual functionVirtual function
Virtual functionharman kaur
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3rohassanie
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Adam Mukharil Bachtiar
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2docSrikanth
 
Unlocking the Magic of Monads with Java 8
Unlocking the Magic of Monads with Java 8Unlocking the Magic of Monads with Java 8
Unlocking the Magic of Monads with Java 8JavaDayUA
 
C Programming Storage classes, Recursion
C Programming Storage classes, RecursionC Programming Storage classes, Recursion
C Programming Storage classes, RecursionSreedhar Chowdam
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementSreedhar Chowdam
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variablesSaurav Kumar
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2rohassanie
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)Olve Maudal
 
C++ Quick Reference Sheet from Hoomanb.com
C++ Quick Reference Sheet from Hoomanb.comC++ Quick Reference Sheet from Hoomanb.com
C++ Quick Reference Sheet from Hoomanb.comFrescatiStory
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++amber chaudary
 

What's hot (20)

FP 201 Unit 3
FP 201 Unit 3 FP 201 Unit 3
FP 201 Unit 3
 
05 -working_with_the_preproce
05  -working_with_the_preproce05  -working_with_the_preproce
05 -working_with_the_preproce
 
12. Java Exceptions and error handling
12. Java Exceptions and error handling12. Java Exceptions and error handling
12. Java Exceptions and error handling
 
Virtual function
Virtual functionVirtual function
Virtual function
 
FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3FP 201 Unit 2 - Part 3
FP 201 Unit 2 - Part 3
 
Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)Algorithm and Programming (Procedure and Function)
Algorithm and Programming (Procedure and Function)
 
C++ programming
C++ programmingC++ programming
C++ programming
 
C++ Presentation
C++ PresentationC++ Presentation
C++ Presentation
 
C aptitude.2doc
C aptitude.2docC aptitude.2doc
C aptitude.2doc
 
Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01Captitude 2doc-100627004318-phpapp01
Captitude 2doc-100627004318-phpapp01
 
Unlocking the Magic of Monads with Java 8
Unlocking the Magic of Monads with Java 8Unlocking the Magic of Monads with Java 8
Unlocking the Magic of Monads with Java 8
 
C Programming Storage classes, Recursion
C Programming Storage classes, RecursionC Programming Storage classes, Recursion
C Programming Storage classes, Recursion
 
Session 3
Session 3Session 3
Session 3
 
C if else
C if elseC if else
C if else
 
C Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory managementC Recursion, Pointers, Dynamic memory management
C Recursion, Pointers, Dynamic memory management
 
Data structure scope of variables
Data structure scope of variablesData structure scope of variables
Data structure scope of variables
 
FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2FP 201 - Unit 3 Part 2
FP 201 - Unit 3 Part 2
 
C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)C++ idioms by example (Nov 2008)
C++ idioms by example (Nov 2008)
 
C++ Quick Reference Sheet from Hoomanb.com
C++ Quick Reference Sheet from Hoomanb.comC++ Quick Reference Sheet from Hoomanb.com
C++ Quick Reference Sheet from Hoomanb.com
 
Conditional statement c++
Conditional statement c++Conditional statement c++
Conditional statement c++
 

Viewers also liked

Chapter 05 polymorphism
Chapter 05 polymorphismChapter 05 polymorphism
Chapter 05 polymorphismNurhanna Aziz
 
Chapter 05 polymorphism extra
Chapter 05 polymorphism extraChapter 05 polymorphism extra
Chapter 05 polymorphism extraNurhanna Aziz
 
Chapter 03 enscapsulation
Chapter 03 enscapsulationChapter 03 enscapsulation
Chapter 03 enscapsulationNurhanna Aziz
 
Chapter 04 inheritance
Chapter 04 inheritanceChapter 04 inheritance
Chapter 04 inheritanceNurhanna Aziz
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanPost Planner
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionIn a Rocket
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting PersonalKirsty Hulse
 

Viewers also liked (7)

Chapter 05 polymorphism
Chapter 05 polymorphismChapter 05 polymorphism
Chapter 05 polymorphism
 
Chapter 05 polymorphism extra
Chapter 05 polymorphism extraChapter 05 polymorphism extra
Chapter 05 polymorphism extra
 
Chapter 03 enscapsulation
Chapter 03 enscapsulationChapter 03 enscapsulation
Chapter 03 enscapsulation
 
Chapter 04 inheritance
Chapter 04 inheritanceChapter 04 inheritance
Chapter 04 inheritance
 
How to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media PlanHow to Build a Dynamic Social Media Plan
How to Build a Dynamic Social Media Plan
 
Learn BEM: CSS Naming Convention
Learn BEM: CSS Naming ConventionLearn BEM: CSS Naming Convention
Learn BEM: CSS Naming Convention
 
SEO: Getting Personal
SEO: Getting PersonalSEO: Getting Personal
SEO: Getting Personal
 

Similar to Chapter 00 revision

Similar to Chapter 00 revision (20)

Java Class Design
Java Class DesignJava Class Design
Java Class Design
 
00_Introduction to Java.ppt
00_Introduction to Java.ppt00_Introduction to Java.ppt
00_Introduction to Java.ppt
 
Java 8 Workshop
Java 8 WorkshopJava 8 Workshop
Java 8 Workshop
 
CSL101_Ch1.ppt
CSL101_Ch1.pptCSL101_Ch1.ppt
CSL101_Ch1.ppt
 
CSL101_Ch1.ppt
CSL101_Ch1.pptCSL101_Ch1.ppt
CSL101_Ch1.ppt
 
CSL101_Ch1.pptx
CSL101_Ch1.pptxCSL101_Ch1.pptx
CSL101_Ch1.pptx
 
CSL101_Ch1.pptx
CSL101_Ch1.pptxCSL101_Ch1.pptx
CSL101_Ch1.pptx
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Java tutorial PPT
Java tutorial  PPTJava tutorial  PPT
Java tutorial PPT
 
Computational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdfComputational Problem Solving 004 (1).pptx (1).pdf
Computational Problem Solving 004 (1).pptx (1).pdf
 
Control Structures in C
Control Structures in CControl Structures in C
Control Structures in C
 
Java tut1
Java tut1Java tut1
Java tut1
 
Tutorial java
Tutorial javaTutorial java
Tutorial java
 
Java Tut1
Java Tut1Java Tut1
Java Tut1
 
Java Tutorial
Java TutorialJava Tutorial
Java Tutorial
 
02 - Prepcode
02 - Prepcode02 - Prepcode
02 - Prepcode
 
a basic java programming and data type.ppt
a basic java programming and data type.ppta basic java programming and data type.ppt
a basic java programming and data type.ppt
 
Loops and conditional statements
Loops and conditional statementsLoops and conditional statements
Loops and conditional statements
 
SystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features SummarySystemVerilog OOP Ovm Features Summary
SystemVerilog OOP Ovm Features Summary
 
Python programing
Python programingPython programing
Python programing
 

Recently uploaded

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfOverkill Security
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Zilliz
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...Zilliz
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdflior mazor
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAndrey Devyatkin
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024The Digital Insurer
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProduct Anonymous
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CVKhem
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsNanddeep Nachan
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)wesley chun
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processorsdebabhi2
 

Recently uploaded (20)

Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
Ransomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdfRansomware_Q4_2023. The report. [EN].pdf
Ransomware_Q4_2023. The report. [EN].pdf
 
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
Emergent Methods: Multi-lingual narrative tracking in the news - real-time ex...
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data DiscoveryTrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
TrustArc Webinar - Unlock the Power of AI-Driven Data Discovery
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
AWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of TerraformAWS Community Day CPH - Three problems of Terraform
AWS Community Day CPH - Three problems of Terraform
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024AXA XL - Insurer Innovation Award Americas 2024
AXA XL - Insurer Innovation Award Americas 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemkeProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
ProductAnonymous-April2024-WinProductDiscovery-MelissaKlemke
 
Real Time Object Detection Using Open CV
Real Time Object Detection Using Open CVReal Time Object Detection Using Open CV
Real Time Object Detection Using Open CV
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)Powerful Google developer tools for immediate impact! (2023-24 C)
Powerful Google developer tools for immediate impact! (2023-24 C)
 
Exploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone ProcessorsExploring the Future Potential of AI-Enabled Smartphone Processors
Exploring the Future Potential of AI-Enabled Smartphone Processors
 

Chapter 00 revision

  • 1. Object Oriented Programming 1 LECTURER: NURHANNA AZIZ ROOM: 3206 EMAIL: NURHANNA@KUIS.EDU.MY HP: 0192223454
  • 2. Prerequisites 2 Must have taken “Introduction to Programming” / “Fundamental of Programming” subject Basic understanding of programming (variables, control flow, branch condition, simple array etc) Student must be able to write a simple program
  • 3. Recommended Books 3 Deitel & Deitel Java How to Program. 2007. Pearson International Edition. Dennis Liang Java Object Oriented Programming. 2009. Thompson Learning C. Thomas Wu. An introduction to Object Oriented Programming with Java. 2004. McGrawHill.
  • 4. Syllabus 4 Object Oriented Programming Method Encapsulation Inheritance Polymorphism Exceptions Java Applet Building Java GUIs GUI Event Handling GUI-based applications
  • 5. Course Evaluation 5 Mid term Test 20% Project 20% Lab Assessments 15% Attendance 5% Final Exam 40%
  • 6. Teaching Outcomes 6 By the end of this module, student should be : Familiar with programming concept within JAVA Able to carry out design and development of complex element such as user interfaces
  • 7. Learning Outcomes 7 An appreciation of the complexities of large programs, and the use of classes and inheritance to manage this complexity The ability to design a collection of classes to implement a large program An appreciation of good programming style (clarity, elegance)
  • 8. How to pass the subject? 8 Continuous Assessment (Coursework) 60% Final Exam 40% For DTCO 3023 – 50% overall to pass For DTCO 3103 & DTCO 3113 – 40% overall to pass Attend the lectures Do assignment, exercise Do all the practical(lab) as best as you can. Project Presentation
  • 9. Attendance 9 Student will be bared from sitting for final exam if Not attend for lectures & lab – 3 times continuously; or Have 30% and more absent record
  • 10. Revision 10
  • 11. Sample of Java Application Program 11 VIEW SOURCE RUN PROGRAM CODE
  • 12. Source Code 12 Name of the class / programs The “main” method
  • 13. Why Java? 13 “Write once, Run Anywhere” Security Network-centric Programming Dynamic, Extensible Program Internationalization Performance Programmer efficiency and time-to-Market
  • 14. Java: Names & Reserved Names 14 Legal name (variables, method, fields, parameter,class, interface or package) Start with: Letter/dollar sign($)/ underscore (_)/ digits(0-9) Reserved names abstract char else goto long public assert class extends if native return boolean const false implements new short break continue final import null static byte default finally instanceof package strictfp case do float int private super catch double for interface protected switch
  • 15. Java Naming Conventions 15 Names of variables, fields, methods: Begin with lowercase letter shape, myShape Name of classes and interfaces: Begin with UPPERCASE letter Cube, ColorCube
  • 16. 16 Named constants: Written fully in UPPERCASE Separated by underscore (_) CENTER, MAX_VALUE, MIN_VALUE If name is composed of several words: First word begins with lowercase, first letter of second word begins with UPPERCASE, the rest back to lowercase setLayout,addPatientName
  • 17. Comments 17 Have no effect on the execution of the program 2 forms: one-line comments E.g. Class Comment { // This is one-line comment, its extends to the end of line } delimited comments E.g. Class Comment { /* This is a delimited comment, extending over several lines */
  • 18. Types 18 Primitive type E.g. boolean,char,byte,short, int, long,float,double Reference type Class type defined/ interface type defined Array type In form [ ]
  • 19. Variables 19 Syntax <Variable-modifier>< type>< variables_name>; E.g. public static void main (String[] args){ int a, b,c; int x=1, y=2,z=3; int myDivide=z/x; double PI=3.1415; boolean isFound=false; }
  • 20. Declaring Variables 20 int x; // Declare x to be an // integer variable; double radius; // Declare radius to // be a double variable; char a; // Declare a to be a // character variable;
  • 21. Assignment Statements 21 x = 1; // Assign 1 to x; radius = 1.0; // Assign 1.0 to a = 'A'; // Assign 'A' to a;
  • 22. Declaring and Initializing in One Step 22 int x = 1; double d = 1.4;
  • 23. Constants 23 final datatype CONSTANTNAME = VALUE; final double PI = 3.14159; final int SIZE = 3;
  • 24. The String Type 24 E.g.: String message = "Welcome to Java"; String Concatenation // Three strings are concatenated String message = "Welcome " + "to " + "Java"; // String Chapter is concatenated with number 2 String s = "Chapter" + 2; // s becomes Chapter2 // String Supplement is concatenated with character B String s1 = "Supplement" + 'B'; // s1 becomes SupplementB
  • 25. Programming Errors 25 Syntax Errors Detected by the compiler Runtime Errors Causes the program to abort Logic Errors Produces incorrect result
  • 26. Converting Strings to Integers 26 use the static parseInt method in the Integer class as follows: int intValue = Integer.parseInt(intString); where intString is a numeric string such as “123”.
  • 27. Converting Strings to Doubles 27 use the static parseDouble method in the Double class as follows: double doubleValue =Double.parseDouble(doubleString); where doubleString is a numeric string such as “123.45”.
  • 28. 28 The Two-way if Statement if (boolean-expression) { statement(s)-for-the-true-case; } else { statement(s)-for-the-false-case; } true false Boolean Expression Statement(s) for the true case Statement(s) for the false case
  • 29. if...else Example 29 if (radius >= 0) { area = radius * radius * 3.14159; System.out.println("The area for the “ + “circle of radius " + radius + " is " + area); } else { System.out.println("Negative input"); }
  • 30. Common Errors 30 Adding a semicolon at the end of an if clause is a common mistake. if (radius >= 0); { area = radius*radius*PI; System.out.println( "The area for the circle of radius " + radius + " is " + area); }
  • 31. switch Statements switch (status) { 31 case 0: compute taxes for single filers; break; case 1: compute taxes for married file jointly; break; case 2: compute taxes for married file separately; break; case 3: compute taxes for head of household; break; default: System.out.println("Errors: invalid status"); System.exit(0); }
  • 32. 32 while Loops int count = 0; while (count < 100) { System.out.println("Welcome to Java"); count++; }
  • 33. while Loop Flow Chart 33 int count = 0; while (loop-continuation- condition) { while (count < 100) { // loop-body; System.out.println("Welcome to Java!"); count++; Statement(s); } } count = 0; Loop false false Continuation (count < 100)? Condition? true true Statement(s) System.out.println("Welcome to Java!"); (loop body) count++; (A) (B)
  • 34. do-while Loop 34 Statement(s) (loop body) true Loop Continuation do { Condition? // Loop body; false Statement(s); } while (loop-continuation-condition);
  • 35. for Loops 35 int i; for (initial-action; loop-continuation- for (i = 0; i < 100; condition; action- i++) { after-each-iteration) { System.out.println( // loop body; "Welcome to Statement(s); } Java!"); } Initial-Action i=0 Loop false false Continuation (i < 100)? Condition? true true Statement(s) System.out.println( (loop body) "Welcome to Java"); Action-After-Each-Iteration i++ (A) (B)
  • 36. Review Questions 36 Problems: 1. Wahid just bought himself a set of home theatre. Declare a variables of TV of type String, speakers of type int, price of type double and goodCondition of type boolean. 2. Amir had 5 history books. Declare an array of book he had.