OOP & JAVA. HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld.

Slides:



Advertisements
Similar presentations
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Advertisements

METHOD OVERRIDING Sub class can override the methods defined by the super class. Overridden Methods in the sub classes should have same name, same signature.
METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
Classes & Objects Computer Science I Last updated 9/30/10.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
1 Java Basics. 2 Compiling A “compiler” is a program that translates from one language to another Typically from easy-to-read to fast-to-run e.g. from.
Principles of Object-Oriented Software Development The language Java.
HST 952 Computing for Biomedical Scientists Lecture 2.
Java Intro. A First Java Program //The Hello, World! program in Java public class Hello { public static void main(String[] args) { System.out.println("Hello,
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
Lecture 1 Introduction to Java MIT- AITI 2004 What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
Applets  The Applet Class  The HTML Tag F Passing Parameters to Applets.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
Writing Classes (Chapter 4)
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
Intro to Java 2 By Geb Thomas Based on the Java TutorialJava Tutorial.
Applets CS 3331 Sections 3.3 & 4.7 of [Jia03].
JAVA APPLETS By: Ms. Humaira Siddiqui. Java and the Internet Java is considered to be a language well suited to be used in the internet. In contrast with.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
Introduction to Java Programming. History F James Gosling and Sun Microsystems F Oak F Java, May 20, 1995, Sun World F HotJava –The first Java-enabled.
Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Spring PImage Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What.
OOP (Java): Simple/ OOP (Java) Objectives – –give some simple examples of Java applications and one applet 2. Simple Java Programs Semester.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
POS 406 Java Technology And Beginning Java Code
1 Programming Fundamentals AITI-GP. 2 Introduction to Programming.
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
Encapsulation, Inheritance & Polymorphism. OOP Properties Encapsulation ­The process of creating programs so that information within a class is not accessible.
SNPL1 Woochang Lim What (Variable) + How (Function) = Object Objects are the physical and conceptual things we find in the universe around us. Object-Oriented.
Introduction to Java Applets Sangeetha Parthasarathy 05/21/2001.
2/4: Objects & Java Applets Objects: their nature –attributes & behaviors –inheritance Java Applets –what is an applet vs. an application? –where do applets.
Methods F Hello World! F Java program compilation F Introducing Methods F Declaring Methods F Calling Methods F Passing Parameters by value F Overloading.
Java applets. Outline What is Java? Java Applications Java Applets Java Applets Securities Summary.
COP2800 – Computer Programming Using JAVA University of Florida Department of CISE Spring 2013 Lecture 35 – Overview of Java Web Programming Webpage:
The 1 st and 2 nd tutoring session of CSc2310 Fall, 2012 Haidong Xue.
1 Programming Paradigms Object Orientated Programming Paradigm (OOP)
Mini University July, 2005 A Little Taste of Java (but don’t tell your folks) (they might think there’s caffeine involved)
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
Object-Oriented Programming with Java Lecture 1: Introduction Autumn, 2007.
Intro to Applets. Applet Applets run within the Web browser environment Applets bring dynamic interaction and live animation to an otherwise static HTML.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
CSI 3125, Preliminaries, page 1 Compiling the Program.
Your name CSCI/CMPE 3326 Object-Oriented Programming in Java Dongchul Kim Department of Computer Science University of Texas – Pan American 1.Applet.
Java Basic Syntax. Object - Objects have states and behaviors. –Example: A dog has states-color, name, breed as well as behaviors -wagging, barking, eating.
Classes - Intermediate
Java Computer Industry Lab. 1 Programming Java Java Basics Incheon Paik.
5.1 Basics of defining and using classes A review of class and object definitions A class is a template or blueprint for an object A class defines.
OOP Basics Classes & Methods (c) IDMS/SQL News
2/4: Objects & Java Applets Objects: their nature –attributes & behaviors –inheritance –information hiding –classes: blueprints for objects Java Applets.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Programs and Models Almost all computer programs model some artifact – Artifact: product of civilization, either concrete or abstract, simple or complex.
Programming in Java Transitioning from Alice. Becomes not myFirstMethod but …. public static void main (String[] arg) { // code for testing classes goes.
Object Oriented Programming Idea Computer program may be seen as comprising a collection of objects Object Fundamental entity in a JAVA program Used to.
Object-Oriented programming for Beginners LEAPS Computing 2015
What is an Object Objects are key to understanding object-oriented technology. An object can be considered a "thing" that can perform a set of related.
Examples of Classes & Objects
OOP What is problem? Solution? OOP
CompSci 230 Software Construction
ATS Application Programming: Java Programming
Interface.
Group Status Project Status.
Java Intro.
Object-Oriented Programming
Road to Object Oriented Programming
Presentation transcript:

OOP & JAVA

HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld { // Display "Hello World!" public static void main(String args[]) { System.out.println("Hello World!"); } Compile: C:\> javac HelloWorld.java Create java bytecode HelloWorld.class Run: C:\> java HelloWorld

HelloWorld.java (Applet) webpage.html HelloWorldApplet.java import java.applet.Applet; import java.awt.Graphics; /** * The HelloWorldApplet class demonstrates * compiling and running an applet within AppletViewer * or a Web browser * * Displays "Hello World!" */ public class HelloWorldApplet extends Applet { public void paint(Graphics g) { g.drawString("Hello world!", 50, 50); }

Definitions of OOP Class A class defines the abstract characteristics of a thing (object), including the thing's characteristics (its attributes or properties) and the things it can do (its behaviors or methods or features).methods For example, the class Dog would consist of traits shared by all dogs, for example breed, fur color, and the ability to bark.

Definitions of OOP Object The class of Dog defines all possible dogs by listing the characteristics that they can have; the object Lassie is one particular dog, with particular versions of the characteristics. A Dog has fur; Lassie has brown-and-white fur. In programmer jargon, the object Lassie is an instance of the Dog class. The set of values of the attributes of a particular object is called its state. state

Definitions of OOP Method An object's abilities. Lassie, being a Dog, has the ability to bark. So bark() is one of Lassie's methods. She may have other methods as well, for example sit() or eat(). Within the program, using a method should only affect one particular object; all Dogs can bark, but you need one particular dog to do the barking.

Definitions of OOP Message passing "The process by which an object sends data to another object or asks the other object to invoke a method."

Definitions of OOP Inheritance

Definitions of OOP Encapsulation Conceals the exact details of how a particular class works from objects that use its code or send messages to it. So, for example, the Dog class has a bark() method. The code for the bark() method defines exactly how a bark happens (e.g., by inhale() and then exhale(), at a particular pitch and volume).

Definitions of OOP Polymorphism is the ability of behavior to vary based on the conditions in which the behavior is invoked, that is, two or more methods, as well as operators (such as +, -, *, among others) can fit to many different conditions. Ex. method signatures would be, respectively, very similar to add(int a, int b) and add(String a, String b). This is an example of Parametric Polymorphism. The returned type and used modifiers, of course, depend on the programmer interests and intentions.

JAVA basics

Java’s Scope Scope is a term used to define where a variable is defined. EX. Function eat(){ int money=100; Print money; } Function buy(){ int money=200; Print money; } main(){ int money=0; eat(); buy(); Print money; }