Lecture 01 Introduction To Programming
Lecture 01 Introduction To Programming
SUBJECT: PROGRAMMING
FUNDAMENTALS
CODE COMP- 1112
FOR MSC MATH
1. Syntax errors
struggle for hours to fix syntax errors
Loose confidence
Frustrating experience
Run away & never come back if possible!
2. Logic errors
Not a serious issue.
Difficulties for experienced programmers
Logic errors
Continuous learning
Lets Start
COMPUTER
Parts of a Computer System:
Decimal
Base 10, ten digits (0-9)
Binary
Base 2, two digits (0-1)
area = 5 * 5 * 3.1415;
21
Compiling Java Source Code
You can port a source program to any machine with
appropriate compilers. The source program must be
recompiled, however, because the object program can only
run on a specific machine. Nowadays computers are
networked to work together. Java was designed to run
object programs on any platform. With Java, you write the
program once, and compile the source program into a
special type of object code, known as bytecode. The
bytecode can then run on any computer with a Java Virtual
Machine. Java Virtual Machine is a software that interprets
Java bytecode.
22
Programming
Conditional Execution
Ifs
Repetition
Looping / Repeating
Procedural
Defining set of steps to transform inputs into outputs
Translating steps into code
Constructed as a set of procedures
Each procedure is a set of instructions
Object-Oriented ( OOP)
Defining/utilizing objects to represent real-world entities
that work together to solve problem
Basic O-O Programming Components
Class
Object/Instance
Properties
Methods
Object Oriented Programming
Class
Specifies the definition of a particular kind of object
Its Characteristics : Properties (or Attributes)
Its Behaviors: Methods
Used as blueprint / template to create objects of that type
Object/Instance
A specific instance of a class – an object created using the
Class Definition
All specific instances of the same class share the same
definition
Same Properties – can be modified
Same Methods – can be modified
Class and Object Example
Color Methods
Walk
Methods
Bark
Walk Jump
Bark (these can also be modified to
Jump fit a particular dog)
Problem Solving
How to solve it