Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.

Slides:



Advertisements
Similar presentations
wwwcsif.cs.ucdavis.edu/~jacksoni
Advertisements

1 pritisajja.info Unlocking the World of Java Programming….. Priti Srinivas Sajja February, 2014 Visit pritisajja.info for detail Future Technology for.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
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.
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,
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Programming in Java; Instructor:Alok Mehta Objects, Classes, Program Constructs1 Programming in Java Objects, Classes, Program Constructs.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Hello, world! Dissect HelloWorld.java Compile it Run it.
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.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Java and C++, The Difference An introduction Unit - 00.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
IT253: Computer Organization Lecture 4: Instruction Set Architecture Tonga Institute of Higher Education.
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
COS 240 Object-Oriented Languages The Anatomy of a Java Program AUBG, Spring 2014 Svetla Boytcheva.
Introduction to Programming David Goldschmidt, Ph.D. Computer Science The College of Saint Rose Java Fundamentals (Comments, Variables, etc.)
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Introduction to Computer Systems and the Java Programming Language.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
CS591x A very brief introduction to Java. Java Developed by Sun Microsystems was intended a language for embedded applications became a general purpose.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
Java Programming Presented by Daniel Rosenthal Friday, November 30 th, 2007.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Introduction to java Prepared By:-Pragnesh Patel Lect. In Computer Dept. NSIT,Jetalpur 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
1 Programming Java Java Basics. 2 Java Program Java Application Program Application Program written in general programming language Applet Program running.
Mixing integer and floating point numbers in an arithmetic operation.
BEGINNING PROGRAMMING.  Literally – giving instructions to a computer so that it does what you want  Practically – using a programming language (such.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Overview of Java CSCI 392 Day One. Running C code vs Java code C Source Code C Compiler Object File (machine code) Library Files Linker Executable File.
By Mr. Muhammad Pervez Akhtar
Duke CPS From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea l What it is ä O-O language, not a hybrid (cf. C++)
Introduction to Java John Lewis. Course Overview Introduction Object Orientated Programming Java Structure and Syntax Using the Java Platform Advanced.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Java Part I By Wen Fei, HAO. Program Structure public class ClassName { public static void main(String[] args) { program statements } user defined methods.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Java Computer Industry Lab. 1 Programming Java Java Basics Incheon Paik.
OOP Basics Classes & Methods (c) IDMS/SQL News
Know Your Java. Java is special Java source code Byte code/ native code Object code on windows Object code on Dos Object code on Lynux.
David Streader Computer Science Victoria University of Wellington Copyright: David Streader, Victoria University of Wellington Java Programing Basics COMP.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Object Oriented Programming Lecture 2: BallWorld.
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.
Introduction to java (class and object). Programming languages: –Easier to understand than CPU instructions –Needs to be translated for the CPU to understand.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
JAVA MULTIPLE CHOICE QUESTION.
Intro to ETEC Java.
Chapter No. : 1 Introduction to Java.
Java Primer 1: Types, Classes and Operators
Internet and Java Foundations, Programming and Practice
Objects, Classes, Program Constructs
An Introduction to Java – Part I
An Introduction to Java – Part I, language basics
Java Intro.
From C++ to Java Java history: Oak, toaster-ovens, internet language, panacea What it is O-O language, not a hybrid (cf. C++) compiled to byte-code, executed.
Chap 1 Chap 2 Chap 3 Chap 5 Surprise Me
Applying OO Concepts Using Java
(Computer fundamental Lab)
Java Programming Language
Introduction to java Part I By Shenglan Zhang.
Presentation transcript:

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries2 Java Features  Java –no pointers –Is interpreted (C/C++ are Compiled) –No Preprocessor –No #define, #ifdef, #include, … –Concurrent –Lots of Librraries –Internet applications –Runs on the client side –Portable –Secure –Event Driven –Easy to Learn

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries3 Example  Hello Class Program public class Hello { // From JEIN public static void main(String argv[]) { System.out.println(”Hello Class\n"); System.exit(0); }  main has a return type of void (not int )  The System.exit method is used to return value back to OS  System.out.println is a print statement.

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries4 Compile/Execute  The file name should be same as class name  There can be multiple classes in the same file (For now, let us consider one class per file)  Class is same as an Object  javac compiles the java code File name has a.java extension eg. Hello.java  It produces a class file (contains java byte code for Java Virtual Machines JVM). Eg. Hello.class  java executes the program

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries5 Other Utilities  Javap -package java.lang.Integer lists the methods and variables that are available in the package java.lang.Integer.  Javap -c <classname. Produces a byte code of your program. Bytecode is written in Java Virtual Machine.  Javadoc produces a HTML file which is a documentation of your program. One can see the documentation using a browser.

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries6 Names and Types  variables  functions, methods  classes or Objects  Types of variables - int, float, double, Boolean  Arrays (unlike C or C++, in Java arrays are treated as an Object.)  Life time of a variable

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries7 Types of Methods and Variables  Instance variable. Instance methods  Static variables and Static Methods  public, private and protected variables and methods  Constructor Method  Automatic Variables

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries8 Import  Import Statement –Without an import statement java.util.Calendar c1; –After the import statement import java.util.Calendar;... Calendar c1; –Saves typing import java.util.*;// Imports all classes

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries9 Examples Public fact { public static int factorial(int n) { if (n==0) return 1 else return n * factorial(n-1); } public static void main(String argv[]) { int x; x=9; System.out.println(“Factorial of”+x+”is”+factorial(x)); }

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries10 Expressions  Arithmetic expressions in Java are similar to C/C++  Example int i = / % 3 = 5 + (12 / 5) - (10 % 3) = = 6 –Operators cannot be overloaded in Java –Integer division vs. floating point division –Operator precedence

Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries11 Objects  Objects  Instances of classes are called objects  Object variables store the address of an object –Different from primitive variables (which store the actual value) –Primitive Data Type example int i=3; int j=i; i=2;// i==2; j==3 –Object Example1 java.awt.Button b1 = new java.awt.Button("OK"); java.awt.Button b2 = b1; b2.setLabel("Cancel"); // Change is visible via b1 also b1 = new java.awt.Button("Cancel")  No explicit dereferencing (i.e., no &, * or -> operators) –No pointers –null = "Absence of reference" = a variable not pointing to an object