220 likes | 268 Views
Java is a programming language that produces software for multiple platforms. When a programmer writes a Java application, the compiled code (known as bytecode) runs on most operating systems (OS), including Windows, Linux and Mac OS. Java derives much of its syntax from the C and C programming languages.
E N D
Object Oriented Programming inJAVA By ProfessionalGuru
Introduction • Welcome to the course Object Oriented Programming in JAVA. This course will cover a core set of computer science concepts needed to create a modern software application using Java. http://professional-guru.com 3 9/15/2011 Object Oriented Programming usingJAVA
CourseObjectives On completion of this course we will be ableto: Identify the importance ofJava . Identify the additional features of Java compared toC++ . Identify the difference between Compiler and Interpreter. Identifythedifferencebetweenappletandapplication. ApplyObjectOrientedPrinciplesofEncapsulations,Data abstraction, Inheritance,Polymorphism. Program using java API (Application ProgrammingInterface). Program using Exception Handling, Files and Threads. Program Using applets and swings. http://professional-guru.com 3 9/15/2011 Object Oriented Programming usingJAVA
CourseSyllabus http://professional-guru.com 3 9/15/2011 Object Oriented Programming usingJAVA
JAVABasics http://professional-guru.com
Why Java isImportant • Two reasons: • Trouble with C/C++ language is that they are not portableand are not platform independent languages. • Emergence of World Wide Web, which demanded portable programs • Portabilityandsecuritynecessitatedthe invention ofJava http://professional-guru.com
History • James Gosling - SunMicrosystems • Co founder – VinodKhosla • Oak - Java, May 20, 1995, SunWorld • JDKEvolutions • – JDK 1.0 (January 23,1996) • – JDK 1.1 (February 19,1997) • – J2SE 1.2 (December 8,1998) • – J2SE 1.3 (May 8,2000) • – J2SE 1.4 (February 6,2002) • – J2SE 5.0 (September 30,2004) • Java SE 6 (December 11,2006) • Java SE 7 (July 28, 2011) http://professional-guru.com
Cont.. • JavaEditions. • J2SE(Java2StandardEdition) -todevelop • client-side standalone applications orapplets. • J2ME(Java2 Micro Edition ) - to develop applications for mobile devices such as cell phones. • J2EE(Java 2 Enterprise Edition ) - to develop server-side applications such as Java servlets and JavaServerPages. http://professional-guru.com
What isjava? • A general-purpose object-orientedlanguage. • Write Once Run Anywhere(WORA). • Designed for easy Web/Internetapplications. • Widespreadacceptance. http://professional-guru.com
How is Java different fromC… • CLanguage: • Major difference is that C is a structure oriented language and Java is an object oriented language and has mechanism to define classes andobjects. • Java does not support an explicit pointertype • Java does not have preprocessor, so we cant use #define, • #include and #ifdefstatements. • Java does not include structures, unions and enum datatypes. • Java does not include keywords like goto, sizeof andtypedef. • Java adds labeled break and continuestatements. • Javaaddsmanyfeaturesrequiredforobjectoriented programming. http://professional-guru.com
How is Java different fromC++… • C++language • Features removed injava: • Java doesn’t support pointers to avoid unauthorized access of memorylocations. • Java does not include structures, unions and enum data types. • Java does not support operator overloading. • PreprocessorplayslessimportantroleinC++andso eliminated entirely injava. • Javadoesnotperformautomatictypeconversionsthat • result in loss ofprecision. http://professional-guru.com
Cont… • Java does not support global variables. Every method and variable is declared within a class and forms partof thatclass. • Java does not allow defaultarguments. • Java does not support inheritance of multiple super classes by a sub class (i.e., multiple inheritance). This is accomplished by using ‘interface’concept. • Itisnotpossibletodeclareunsignedintegersinjava. • In java objects are passed by reference only. In C++ objects may be passed by value orreference. http://professional-guru.com
Cont… • New features added inJava: • Multithreading, that allows two or more pieces of the same program to executeconcurrently. • C++ has a set of library functions that use a common header file. But java replaces it with its own set of API classes. • It adds packages andinterfaces. • Java supports automatic garbagecollection. • break and continue statements have been enhanced in java to accept labels astargets. • The use of unicode characters ensuresportability. http://professional-guru.com
Cont… • Features thatdiffer: • Though C++ and java supports Boolean data type, C++ takes any nonzero value as true and zero as false. True and false in java are predefined literals that are values for a boolean expression. • Java has replaced the destructor function with a finalize() function. • C++ supports exception handling that is similar to java's. However, in C++ there is no requirement that a thrown exception becaught. http://professional-guru.com
Characteristics ofJava • Java issimple • Java isobject-oriented • Java isdistributed • Java isinterpreted • Java isrobust • Java isarchitecture-neutral • Java isportable • Java’sperformance • Java ismultithreaded • Java isdynamic • Java issecure http://professional-guru.com
JavaEnvironment • Java includes many development tools, classes and methods • Development tools are part of Java Development Kit (JDK)and • The classes and methods are part of Java Standard Library (JSL), also known as Application Programming Interface(API). • JDK constitutes oftoolslikejavacompiler,java • interpreter andmany. • API includes hundreds of classes and methodsgrouped into several packages according to theirfunctionality. http://professional-guru.com
Java isarchitecture-neutral JAVA ProgramExecution http://professional-guru.com 9/15/2011 Object Oriented Programming usingJAVA
WORA(Write Once RunAnywhere) http://professional-guru.com 9/15/2011 Object Oriented Programming usingJAVA
Editplus for JavaProgramming • Edit PlusSoftware: • EditPlus isa 32-bit text editor for the Microsoft Windows operatingsystem. • The editor contains tools for programmers, including syntax highlighting (and support for custom syntax files), file type conversions, line ending conversion (between Linux, Windows and Macstyles), regular expressions for search-and-replace, spell checketc). http://professional-guru.com 9/15/2011 Object Oriented Programming usingJAVA
Hello world Program injava http://professional-guru.com 9/15/2011 Object Oriented Programming usingJAVA
Execution of Hello worldProgram http://professional-guru.com 9/15/2011 Object Oriented Programming usingJAVA
http://professional-guru.com 9/15/2011 Object Oriented Programming usingJAVA