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.

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

1 Packages: Putting Classes Together. 2 Introduction The main feature of OOP is its ability to support the reuse of code: Extending the classes (via inheritance)
ICS 201 Inheritance Introduction to Computer Science
CS 106 Introduction to Computer Science I 04 / 11 / 2008 Instructor: Michael Eckmann.
9. Inheritance 9.1 Subclasses 9.2 Polymorphism 9.3 Abstract Classes 9.4 Modifiers and Access 9.6 Object-Oriented Design with Use Cases and Scenarios.
ITEC200 – Week03 Inheritance and Class Hierarchies.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
CS 106 Introduction to Computer Science I 04 / 16 / 2010 Instructor: Michael Eckmann.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
Advanced Object-Oriented Programming Features
Chapter 10 Classes Continued
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Introduction to Java Programming Language Junji Zhi University of Toronto 1.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Packages.
C++ Object Oriented 1. Class and Object The main purpose of C++ programming is to add object orientation to the C programming language and classes are.
Chapter 12 Inheritance and Exceptions Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas,
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Chapter 11 Inheritance and Composition. Chapter Objectives Learn about inheritance Learn about subclasses and superclasses Explore how to override the.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
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.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
JAVA BASICS Prepared by The Smartpath Information Systems
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.
Data Structures Using C++ 2E1 Inheritance An “is-a” relationship –Example: “every employee is a person” Allows new class creation from existing classes.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
Programming in Java CSCI-2220 Object Oriented Programming.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
Object Oriented Programming
CS-1030 Dr. Mark L. Hornick 1 Basic C++ State the difference between a function/class declaration and a function/class definition. Explain the purpose.
Department of Computer Science Data Structures Using C++ 2E Chapter 2 Object-Oriented Design (OOD) and C++  Learn about inheritance  Learn about derived.
Java Software Solutions Lewis and Loftus Chapter 9 1 Copyright 1997 by John Lewis and William Loftus. All rights reserved. Enhanced Class Design -- Introduction.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Inheritance Inheritance is the process of extending the functionality of a class by defining a new class that inherit,all the features of extending class.
Classes, Interfaces and Packages
Packages. The main feature of OOP is its ability to support the reuse of code: –Extending the classes –Extending interfaces The features in basic form.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
C++ General Characteristics: - Mixed typing system - Constructors and destructors - Elaborate access controls to class entities.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Programming With Java ICS201 University Of Ha’il1 ICS 201 Introduction to Computer Science Inheritance.
Object Oriented Programming in
Modern Programming Tools And Techniques-I
Inheritance-Basics.
Inheritance and Polymorphism
Packages When we name a program , we name it by class name…
Internet and Java Foundations, Programming and Practice
Java Programming Language
Interfaces.
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.
Inheritance Inheritance is a fundamental Object Oriented concept
Java Evolution Java History. Java Features.
Final and Abstract Classes
Interfaces,Packages and Threads
Presentation transcript:

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 From C? 1. Java does not include the C unique statement, keywords goto, sizeof, and typedef. 2. Java does not support an explicit pointer type. 3. Java adds new operator such as instanceof and >>> 4. Java adds labeled break and continue statements. 5. Java does not have a preprocessor and therefore we cannot use #define, #include, and #ifdef statements. How Java Differs From C++? 1. Java does not support operator overloading. 2. Java does not have template classes as in C Java does not support multiple inheritance of classes. 4. Java does not support global variables. 5. Java does not use Pointers 6. Java has replaced the destructor function with a finalize() function. 7. There are no header files in Java.

Java Compilation Process Java Source CodeJava CompilerJava Byte Code (Java Class File) Java InterpreterJava Machine Code What are the Java Features or Buzzwords. 1. Compiled and Interpreted 2. Platform – Independent and Portable 3. Object – Oriented 4. Robust and Secure 5. Distributed 6. Familiar, Simple and Small 7. Multithreaded and Interactive 8. High Performance 9. Dynamic and Extensible

What are the access leveling of the different access control? private -Same class in Same package private protected-Sub class in Same package friendly-Non – Sub class in Same package protected- Sub class in Other package public -Other class in Other Package What are the restrictions of the Static Method? 1. They can only call other static methods. 2. They must only access static data. 3. They cannot refer to this or super in any way. What is the Purpose of final keyword? a. Can’t redefined the initialization of the variable b. Can’t Method Overriding c. Can’t Inherit the Other class.

A B C D E Pacakge X Pacakge Y

ACCESS PROTECTION Access Modifier Access Location PublicProtectedfriendly (default) private protected private Same ClassYes Subclass in same package Yes No Other classes in same package Yes No Subclass in other package Yes NoYesNo Non – subclasses in other packages YesNo

What are the conditions for the Abstract Classes? 1. We cannot use abstract classes to instantiate objects directly. For example. Shape s = new Shape(); is illegal because shape is an abstract class 2. The abstract methods of an abstract class must be defined in its subclass 3. We cannot declare abstract constructors or abstract static methods. What are the differences between Abstract Classes and Interfaces? Abstract classesInterfaces Abstract classes are used only when there is a “is-a” type of relationship between the classes. Interfaces can be implemented by classes that are not related to one another. You cannot extend more than one abstract class.You can implement more than one interface. it contains both abstract methods and non abstract methods Interface contains all abstract methods Abstract class can implemented some methods also.Interfaces can not implement methods. With abstract classes, you are grabbing away each class’s individuality. With Interfaces, you are merely extending each class’s functionality.

What are the differences between Class and Interfaces ClassesInterfaces Create a object for the Class.Can’t Create the object for the interface. Class can’t support multiple Inheritances.Interface can support multiple Inheritances. The methods present in classes are well defined.The methods present in interfaces are pure abstract (only declaration). The access specifiers public, private, protected are possible with classes. But the interface uses only one spcifier public Class contain for the member declaration as well as member definition. Interface contain only for the member declaration.

PACKAGES What is Packages? Packages are java’s way of grouping a variety of classes and / or interfaces together. The grouping is usually done according to functionality. In fact, packages act as “containers” for classes. Types of Packages Java packages are therefore classified into two types. 1. Pre – defined packages (Java API Packages) 2. User – defined packages

Java API Packages Package NameContents java.langLanguage support classes. These are classes that java compiler itself uses and therefore they are automatically imported. They include classes for primitive types, strings, math functions, threads and exceptions java.utilLanguage utility classes such as vectors, hash tables, random numbers, date, etc. java.ioInput / Output support classes. They provide facilities for the input and output of data. java.awtSet of classes for implementing graphical user interface. They include classes for windows, buttons, lists, menus and so on. java.netClasses for networking. They include classes for communicating with local computers as well as with internet servers. java.appletClasses for creating and implementing applets.

USER DEFINED PACKAGES How to Creating our own Packages Creating our own package involves the following steps: 1. Declare the package at the beginning of a file using the form package package_name; 2. Define the class that is to be put in the package and declare it public 3. Create a subdirectory under the directory where the main source files are stored. 4. Store the listing as the classname.java file in the subdirectory created. 5. Compile the file. This creates.class file in the subdirectory. 6. The subdirectory name must match the package name exactly. Note: Java also supports the concept of package hierarchy. This done by specifying multiple names in a package statement, separated by dots. Example: package firstPackage.secondpackage;