CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

Introduction to Java 2 Programming Lecture 4 Writing Java Applications, Java Development Tools.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lecture 2: Object Oriented Programming I
Lab#1 (14/3/1431h) Introduction To java programming cs425
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
How to Create a Java program CS115 Fall George Koutsogiannakis.
Aalborg Media Lab 21-Jun-15 Software Design Lecture 1 “ Introduction to Java and OOP”
HST 952 Computing for Biomedical Scientists Lecture 2.
Chapter 1 Introduction.
Introduction to Java.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
+ 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.
Java 程序设计 Java Programming Fall, Contents for Today Java Program Structure  How to Compile a Java Program  How to Run a Java Program Environment.
Java Programming Robert Chatley William Lee
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
Chapter 1: Creating Java Programs
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
MT311 Java Application Development and Programming Languages Li Tak Sing( 李德成 )
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Introduction to JNI Prepared by Humaira Siddiqui.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
JAVA JAVA is an object-oriented programming (OOP) language introduced by Sun Microsystems in In the Java programming language: A program is made.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
1 CSC204 – Programming I Lecture 2 Intro to OOP with Java.
POS 406 Java Technology And Beginning Java Code
Java Programming, Second Edition Chapter One Creating Your First Java Program.
COP 3330 Notes 1/12. Today's topics Downloading Java and Eclipse Hello World Basic control structures Basic I/O Strings.
JAVA BASICS Prepared by The Smartpath Information Systems
Introduction to Object Oriented Programming CMSC 331.
Lecture 1 Introduction Figures from Lewis, “C# Software Solutions”, Addison Wesley Richard Gesick.
EE2E1. JAVA Programming Lecture 3 Java Programs and Packages.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
JAVA COURSE 1 Computer Engineering Association. Compile your first program Public class Hello{ public class Hello(){ System.out.println(“Hello”); } puclic.
22-July-2002cse142-13B-Development © 2002 University of Washington1 Development Tools CSE 142, Summer 2002 Computer Programming 1
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
1 Chapter 5: Defining Classes. 2 Basics of Classes An object is a member of a class type What is a class? Fields & Methods Types of variables: –Instance:
Inheritance CSI 1101 Nour El Kadri. OOP  We have seen that object-oriented programming (OOP) helps organizing and maintaining large software systems.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Classes, Interfaces and Packages
CSCI 212 Object-Oriented Programming in Java. Prerequisite: CSCI 111 variable assignment statement while loop for loop post-increment (i++) strong typing.
An Introduction to Programming with C++ Fifth Edition Chapter 14 Classes and Objects.
Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.
RealTimeSystems Lab Jong-Koo, Lim
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Object Oriented Programming CMSC 331. Concept of Abstraction “An abstraction is a view or representation of an entity that includes only the attributes.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
CS-140 Dick Steflik Lecture 3. Java C++ Interpreted optimized for the internet Runs on virtual ized machine Derived from C++ Good object model Widely.
Lecture 1b- Introduction
Modern Programming Tools And Techniques-I
JAVA MULTIPLE CHOICE QUESTION.
Before You Begin Nahla Abuel-ola /WIT.
University of Central Florida COP 3330 Object Oriented Programming
Internet and Java Foundations, Programming and Practice
Programming without BlueJ Week 12
University of Central Florida COP 3330 Object Oriented Programming
Introduction to Java Dept. Business Computing University of Winnipeg
CS-0401 INTERMEDIATE PROGRAMMING USING JAVA
Introducing Java.
Chap 1. Getting Started Objectives
Chap 4. Programming Fundamentals
Presentation transcript:

CSCE 2013L: Lab 1 Overview  Java Basics The JVM Anatomy of a Java Program  Object-Oriented Programming Overview  Example: Payroll.java JDK Tools and Classpath  Lab Programs Pay.java  Compile and execute a simple Java program SalesTax.java  Basic program debugging

The Java Virtual Machine Source.java compiles to Source.class as bytecode for the JVM The JVM converts the bytecode into native machine code

Object-Oriented Programming Overview Object  Data: Known as its “attributes” and represents the object's state  Procedures: When a procedure is part of an object, it is called a “method”. They represent the interface to use the object. Encapsulation  Usually refers to combining procedures and data in this way.  Offers data-hiding to the object so that only the object can access its attributes. This lets the object keep itself in a valid state.

OOP Overview cont. Access Control  The means through which an object controls who can see and manipulate its data and methods. Public: Anyone can access. This is part of the interface. Private: This is part of the internal implementation. Only that object has access. Class  This is the prototype or blueprint that allows one to make individual “instances” of an object.

OOP final Inheritance  Provides a way to specialize classes to add new functionality or change the behavior to something more suitable.  The class that is inherited from is the “base” class and is known as a “superclass.” The inheriting classes are “derived” classes and are “subclasses.”  Subclasses gain all the attributes and methods of the superclass and can define completely new ones or change the behavior of existing methods.

Example: Payroll.java public class Payroll { public static void main(String[] args)‏ { int hours = 40; double grossPay, payRate = 25.0; grossPay = hours * payRate; System.out.println("Your gross pay is $" + grossPay); }

JDK Tools javac  used to compile Source.java into bytecode outputs Source.class Example:  javac Payroll.java  output: Payroll.class java  starts an instance of the JVM that runs the bytecode on the target platform Example:  java Payroll There is no need to specify.class.

Classpath Provides a way to tell the Java compiler and JVM where user-defined classes and packages are located. It can be specified for javac or java through the command line option -cp /path/classes or through the environment variable CLASSPATH  Windows: set CLASSPATH=C:\location\classes  Linux: export CLASSPATH=/path/classes

Packages Provides a way to organize classes into functional units and avoid name clashes with other libraries. Declare “package base.sub.etc;” at the top of a file. The corresponding directory/folder structure on disk would be “base/sub/etc” java[c] -cp rootdir [options]  where “rootdir” means the directory that contains base and its subfolders (but is not base itself).

Pay.java and SalesTax.java Pay.java  javac Pay.java  java Pay The calculation changes based on number of hours worked. Figure out this point and test above, at, and below it. SalesTax.java  Contains syntactic and semantic errors Correct these errors so that it outputs the correct sales tax and final price Document the errors and their lines in the provided worksheet

Caveats These programs expect their numeric input in the form of a double. Therefore, make sure to end the integer part with a dot (.) if you desire a whole number. Examples:  40.  40.0  40.5 You will get an exception at runtime (a program failure) if you fail to format the input in the manner expected.