Object-Oriented programming for Beginners Object-Oriented programming for Beginners

Object-Oriented programming for Beginners - PowerPoint Presentation

danika-pritchard . @danika-pritchard
Uploaded On 2018-03-12

Object-Oriented programming for Beginners - PPT Presentation

LEAPS Computing 2015 Ioannis Efstathiou ie24hwacuk slides originally made by Rajiv Murali HeriotWatt University Learning Outline Setting up Eclipse Simple HelloWorld program Basic ObjectOriented Programming Concept ID: 648637

object class age human class object human age frank objects step oriented programming eclipse void humandemo state java behaviour methods project statements




Download Presentation from below link

Download Presentation The PPT/PDF document "Object-Oriented programming for Beginner..." is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.

Presentation Transcript


Object-Oriented programming for BeginnersLEAPS Computing 2015




(slides originally made by Rajiv




Learning Outline

Setting up Eclipse

Simple HelloWorld program.

Basic Object-Oriented Programming Concept

What is an Object?

What is a Class?

Language Basics



Expressions, Statements and Blocks

Control Flow Statements

Conditional Statements,Loop statements


Simple Eclipse Start-UpSlide4

Creating a Java Project in Eclipse IDE

Step 1: Start Eclipse

Step 2: Click File > New > Java Project

Step 3: Enter a Project name, e.g. “JavaTutorial”, and click “Finish”.

Step 4: Right-click on the project folder and select New > Class.

Step 5: Enter “HelloWorldDemo” as the name, and click “Finish”.

Step 6: Edit the HelloWorldDemo.class file as follows:

public class HelloWorldDemo {

public static void main(String args[ ]) {

System.out.println("Hello World!");



Step 7: Run the HelloWorldDemo.class.Slide5

Assignment HelloWorld

In this assignment I want you to use the HelloWorldDemo Class to:

output the following message

: “Hello World! my name is #your name here#!”Slide6

Object-Oriented ProgrammingSlide7

Object-Oriented Programming

Java is an Object-Oriented Programming Language.

Before you begin writing Java code, you will need to learn a few basic object-oriented concepts.

This lesson will introduce you to:

what is an Object?

what is a Class?

To help better understand these concepts, we will relate them to examples Java code that you will run in your

Eclipse IDE.Slide8

What is an Object?

Look around right now and you'll find many examples of real-world



your desk, your books, your computers and even yourselves.

Objects share two characteristics: State and Behaviour.

For example an object Person may have:

state - name, age, weight, etc.

behavior - walking, eating, sleeping, etc.

Take a minute and think of some examples of Objects around you, with some state and behaviour.Slide9

Objects in Software

Similar to real-world objects, software objects also consist of state and behaviour.

A software object stores its...

states in fields, also known as


in most programming languages.

while its behaviour is exposed through



an Object -








Methods help to operate an object's internal state.Slide10

What is a Class?

Often there are many individual objects of the same kind.

There are billions of people in existence, and all people fall under the kind human.

A Class helps to capture the common features of objects.

And from a Class, many instances of Objects may be created.

In object-oriented terms, we say that an Object person is an instance of a Class Human.Slide11

What does Class Human look like in code?

class Human {

int age;

string name;

void increaseAge() {



void setNameandAge(String parameterName, int parameterAge) {

name = parameterName;

age = parameterAge;


void printHumanInfo() {

System.out.println(“Name: ”+ name);

System.out.println(“Age: ” +age);




Field / Variable


Creating an object from Human Class…

We want to create a person from our human class...

But the Human class is not a complete application!

It does not contain a



The responsibility of creating and using people from the human class belongs to another application….Slide13

HumanDemo Class

class HumanDemo {

public static void main(String[] args){

Human frank = new Human();

frank.setNameandAge(“Frank”, 10);




The HumanDemo Class helps creates an instance frank of the Human class. We then set the name and age of Frank to 10.

Program Execution

Creates an instance frank from the Human Class.

Sets the name and age of frank.

Prints the information of frank.Slide14

Assignment HumanDemo

In this assignment I want you to use the HumanDemo Class to:

1. Set the age of frank to 100.

2. Set the name of frank to “Frankenstein”.

3. Print the



4. Then increase Franks age by 3.

5. And finally, print the information again.