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.

Slides:



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

Introduction to Java 2 Programming Lecture 3 Writing Java Applications, Java Development Tools.
STRING AN EXAMPLE OF REFERENCE DATA TYPE. 2 Primitive Data Types  The eight Java primitive data types are:  byte  short  int  long  float  double.
Portability and Safety Mahdi Milani Fard Dec, 2006 Java.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
The Java Language. Topics of this Course  Introduction to Java  The Java Language  Object Oriented Programming in Java  Exceptions Handling  Threads.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Applying OO Concepts Using Java. In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The.
Introduction to Java Programming Language Junji Zhi University of Toronto 1.
Peter Juszczyk CS 492/493 - ISGS. // Is this C# or Java? class TestApp { static void Main() { int counter = 0; counter++; } } The answer is C# - In C#
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
CPS 108 : Spring From C++ to Java l Java history: Oak, toaster-ovens, internet language, panacea  Not really a standard language like C++  Arguably.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
OOP Languages: Java vs C++
Programming Languages and Paradigms Object-Oriented Programming.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Java and C++, The Difference An introduction Unit - 00.
“is a”  Define a new class DerivedClass which extends BaseClass class BaseClass { // class contents } class DerivedClass : BaseClass { // class.
Cs3180 (Prasad)L8Packages1 Packages Organizing large programs => From monolithic programs to partitioning class name space Access control of names => Enforcing.
Introduction to Java. 2 Module Information Programming conceptsPrerequisites Beginners in JAVATarget Audience This module will provide you a solid grounding.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
Object Oriented Programming: Java Edition By: Samuel Robinson.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
Java Programming A Brief Intro. Overview of Java  Java Features  How Java Works  Program-Driven vs Event Driven  Graphical User Interfaces (GUI)
May 9, 2002Serguei A. Mokhov, 1 Kickstart Intro to Java Part I COMP346/ Operating Systems Revision 1.6 February 9, 2004.
Basic Java Syntax CSE301 University of Sunderland Harry R Erwin, PhD.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
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.
Introduction to Object Oriented Programming CMSC 331.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java Basics Opening Discussion zWhat did we talk about last class? zWhat are the basic constructs in the programming languages you are familiar.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Java: An Overview John R Durrett Texas Tech University.
1 The JAVA Language Object Oriented Technology Mithani Binjan M.
JAVA INTRODUCTION. What is Java? 1. Java is a Pure Object – Oriented language 2. Java is developing by existing languages like C and C++. How Java Differs.
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++)
Classes, Arrays & Pointers. Compiler & Linker expectations file1.cppfile2.cppfilen.cpp …. file1.ofile2.ofilen.o …. Linker application (executable) Compiler.
Java & C++ Comparisons How important are classes and objects?? What mechanisms exist for input and output?? Are references and pointers the same thing??
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
© 2006 Pearson Addison-Wesley. All rights reserved 1-1 Chapter 1 Review of Java Fundamentals.
20-753: Fundamentals of Web Programming Copyright © 1999, Carnegie Mellon. All Rights Reserved. 1 Lecture 15: Java Basics Fundamentals of Web Programming.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
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.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
EECE 309: Software Engineering
CIS 068 JAVA vs. C++ Main Differences CIS 068.
Object Oriented Programming in
Concurrent Object-Oriented Programming Java (VRH 7.7,8.6)
JAVA MULTIPLE CHOICE QUESTION.
Chapter No. : 1 Introduction to Java.
Internet and Java Foundations, Programming and Practice
Introduction Enosis Learning.
Introduction Enosis Learning.
Advanced Programming Fall 2017.
Java Programming Language
Object Oriented Programming
Applying OO Concepts Using Java
(Computer fundamental Lab)
Java Programming Language
Java Basics Data Types in Java.
Presentation transcript:

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 on JVM byte-code is “highly-portable”, write once run “anywhere” simple, object-orientd, portable, interpreted, robust, secure, architecture-neutral, distributed, dynamic, multithreaded, high performance create both applets and applications current version 1.1 (1.1.4), 1.2 out in December browsers support 1.0.X

Java Fundamentals primitive types: int, double, char, boolean (and some others tha differ in size, e.g., float, long) size of int is guaranteed to be 32 bits (unlike, say, C++) these primitive types are different than all other types, do NOT belong to inheritance hierarchy All other types descend from base type Object, must be allocated using new no delete, garbage collection is automatic all parameters are passed by value, no reference params everything is a pointer or isn’t a pointer --- can change value of parameter via a method call no address operator, “safe pointers”

Java stuff string immutable, once set cannot be changed (but make a new one) concatenation using +, this is the only non-arithmetic use of +, in Java no user-defined overloaded operators array and vector array is typed, non-growable, random-access collection vector is non-typed, growable, random-access collection casting out of function calls (e.g., container get) is required, casting is checked at runtime, therefore safe

Compiling/Executing Java Programs class Foo must be stored in Foo.java file name corresponds to class name directory hierarchy corresponds to package hierarchy package is set of related classes compile, run, document javac, compiler: javac -deprecation Foo.java java, runtime: java Foo javadoc: javadoc -author *.java CLASSPATH environment variable import java.lang.* different from #include in C++, namespace device

Inheritance, Interfaces All classes in Java extend the class Object explicit extension/inheritance is possible, but only single inheritance possible to implement multiple interfaces An interface is like an abstract base class, all methods/member functions must be implemented example: Enumeration is an iterator interface boolean hasMoreElements() Object nextElement() Possible to declare an object of type Enumeration, but cannot use new Enumeration

Public, private, protected, package similar to use in C++ public methods/classes callable from client code private methods/instance variables not accessible NO FRIENDs protected limits access to subclasses no designation is package access Package is a module of related classes package classes can access all package functions/data can be used like friend functions --- belong to a package directory hierarchy mimics package designation, CLASSPATH must be set properly