Presentation For Object Oriented Programming
Presentation For Object Oriented Programming
*****
Signature consists of 2 parts of
method
• NAME
• ARGUMENT
⚫ Many IDEs are designed specifically for Java programming, but we chose
3
ECLIPSE IDE and will use for labs.
19.10.2023 23:15
1.4 Programming Environment
Your First Program
Compile
Output Execute
5
19.10.2023 23:15
1.4 Programming Environment
Source Code to Running Program
7
19.10.2023 23:15
1.5 Analyzing your First Program
First Program
9
19.10.2023 23:15
1.5 Analyzing your First Program
Calling Java Library methods
System.out.print("00"); 007
System.out.println(3+4);
A method is called by specifying
11 the method and its agruments
19.10.2023 23:15
1.6 Errors
Common Error 1.1
❑ Omitting Semicolons
▪ In Java, every statement must end in a semicolon.
Forgetting to type a semicolon is a common error. It
confuses the compiler, because the compiler uses the
semicolon to find where one statement ends and the
next one starts. For example, the compiler sees this:
System.out.println("Hello")
System.out.println("World!");
▪ As this:
System.out.println("Hello") System.out.println("World!");
▪ It doesn’t understand this statement, because it does
12 not expect the word System following the closing
19.10.2023 23:15 parenthesis after Hello.
1.6 Errors
Errors
18
19.10.2023 23:15 Report the final year value as the answer
1.7 Problem Solving: Algorithm Design
Text Problem to Pseudocode
❑ Pseudocode
▪ Half-way between natural language and a
programming language
Pseudocode is an informal
❑ Modified Steps description of a sequence of
▪ Set the year value of 0
steps for solving a problem
❑ An algorithm describes a
sequence of steps that is:
▪ Unambiguous
• Do not require ‘assumptions’
• Uses precise instructions
▪ Executable
• Can be carried out in practice
▪ Terminating
• Will eventually come to an end
20
19.10.2023 23:15
1.7 Problem Solving: Algorithm Design
Steps: Algorithm to Pseudocode
You have the choice of buying two cars. One is more fuel efficient than the
other, but also more expensive. You know the price and fuel efficiency (in miles
per gallon, mpg) of both cars. You plan to keep the car for ten years. Which car
is the better deal?