Presentation is loading. Please wait.

Presentation is loading. Please wait.

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.

Similar presentations


Presentation on theme: "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."— Presentation transcript:

1 JAVA INTRODUCTION

2 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++. 3. 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.

3 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

4 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.

5 A B C D E Pacakge X Pacakge Y

6 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

7 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.

8 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.

9 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

10 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.

11 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;


Download ppt "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."

Similar presentations


Ads by Google