CSC1016s
2021
, OOP in Java
(Object-Orientated Programming)
Procedural Programming
o Writing procedures that perform data operations.
Object-Orientated Programming
o Creating objects that contain both data and methods.
Why OOP is better than PP:
Faster and easier to execute.
Provides a clear structure for the programs.
Helps to keep Java ode DRY (Don’t Repeat Yourself),
making the code easier to maintain, modify, and debug.
Makes it possible to create full reusable apps in less code
and shorter development time.
Introduction to Java
Considered a language for Internet apps.
General purpose programming language.
Syntax is similar to that of other high-level languages.
Origins
Created by Sun Microsystems, led by James Gosling, in ’91.
Now, owned by Oracle.
Originally designed for programming home appliances.
o Difficult task, as appliances are controlled by a wide
range of computer processers.
, o Team developed a two-step translation process to
simplify the task of compiler writing for each
appliance class…
• Writing a compiler (translation program) for each
appliance processer type = expensive.
• Rather, developed intermediate language that I the
same for all processor types: Java byte-code.
• Thus, only a small, easy-to-write program was needed to
translate byte code to machine code for each
processor.
In 1994, at Sun Microsystems, Patrick Naughton and
Jonathan Payne developed a Web browser that could run
programs over the Internet.
o Beginning of Java’s connection to the Internet.
o Original browser evolves into HotJava.
…other companies followed suit.
Objects and Methods
OOP is a programming methodology that views programs
as consisting of objects that interact through methods.
Objects of the same kind have same type or in same class.
Java Application Programs
Two types…
Application Programs
“regular”
A class with a method named main.
When run, the run-time system automatically invokes main.
All start with the main method.
May use a windowing interface or console IO.
, Applet Programs
“Little Java application”
Meant to be run from a Web browser.
Can be run from a location on the Internet.
Can be run on Applet viewer program for debugging.
Always use a windowing interface.
Computer Language Levels
High-Level Language:
…people can read, write, and understand.
Must be translated into a language that can be
understood by a computer before it can be run.
Machine Language:
…computer can understand.
Low-Level Language:
…Machine Language / any similar to Machine Language.
Compiler:
…program that translated High-Level Language programs
into equivalent Low-Level Language programs.
Translation process = compiling.
2021
, OOP in Java
(Object-Orientated Programming)
Procedural Programming
o Writing procedures that perform data operations.
Object-Orientated Programming
o Creating objects that contain both data and methods.
Why OOP is better than PP:
Faster and easier to execute.
Provides a clear structure for the programs.
Helps to keep Java ode DRY (Don’t Repeat Yourself),
making the code easier to maintain, modify, and debug.
Makes it possible to create full reusable apps in less code
and shorter development time.
Introduction to Java
Considered a language for Internet apps.
General purpose programming language.
Syntax is similar to that of other high-level languages.
Origins
Created by Sun Microsystems, led by James Gosling, in ’91.
Now, owned by Oracle.
Originally designed for programming home appliances.
o Difficult task, as appliances are controlled by a wide
range of computer processers.
, o Team developed a two-step translation process to
simplify the task of compiler writing for each
appliance class…
• Writing a compiler (translation program) for each
appliance processer type = expensive.
• Rather, developed intermediate language that I the
same for all processor types: Java byte-code.
• Thus, only a small, easy-to-write program was needed to
translate byte code to machine code for each
processor.
In 1994, at Sun Microsystems, Patrick Naughton and
Jonathan Payne developed a Web browser that could run
programs over the Internet.
o Beginning of Java’s connection to the Internet.
o Original browser evolves into HotJava.
…other companies followed suit.
Objects and Methods
OOP is a programming methodology that views programs
as consisting of objects that interact through methods.
Objects of the same kind have same type or in same class.
Java Application Programs
Two types…
Application Programs
“regular”
A class with a method named main.
When run, the run-time system automatically invokes main.
All start with the main method.
May use a windowing interface or console IO.
, Applet Programs
“Little Java application”
Meant to be run from a Web browser.
Can be run from a location on the Internet.
Can be run on Applet viewer program for debugging.
Always use a windowing interface.
Computer Language Levels
High-Level Language:
…people can read, write, and understand.
Must be translated into a language that can be
understood by a computer before it can be run.
Machine Language:
…computer can understand.
Low-Level Language:
…Machine Language / any similar to Machine Language.
Compiler:
…program that translated High-Level Language programs
into equivalent Low-Level Language programs.
Translation process = compiling.