0% found this document useful (0 votes)
6 views

Introduction to OOP in Java

Uploaded by

saadbink1234
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Introduction to OOP in Java

Uploaded by

saadbink1234
Copyright
© © All Rights Reserved
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 17

OBJECT ORIENTED

PROGRAMMING
INTRODUCTION TO JAVA
INTRODUCTION JAVA

• Java is a programming language invented by James Gosling and others


in 1994.

• Originally named Oak,was developed as a part of the Green project at


the Sun Company.

• A general-purpose object-oriented language Based on C/C++.


Designed for easy Web/Internet applications. Widespread acceptance.
JAVA FEATURES

• Java is simple
• Java is object-oriented
• Java is distributed
• Java is interpreted
• Java is robust
• Java is secure
• Java is architecture-neutral
• Java is portable
• High performance
• Java is dynamic
JAVA FEATURES

Simple
• Fixes some clumsy features of C++
• No pointers
• Automatic garbage collection
Object Oriented Programming
• Focus on the data (objects) and methods manipulating the data
• All functions are associated with objects
• Almost all datatypes are objects (files, strings, etc.)
• Potentially better code organization and reuse
JAVA FEATURES

Complied and Interpreted


• java compiler generate byte-codes, not native machine code
• the compiled byte-codes are platform-independent
• java bytecodes are translated on the fly to machine readable instructions in runtime (Java
Virtual Machine)

Platform Independent and Portable


• same application runs on all platforms
• the sizes of the primitive data types are always the same
• the libraries define portable interfaces.
PLATFORM INDEPENDENT
JAVA FEATURES

Reliable (Robust)
• Extensive compile-time and runtime error checking.
• No pointers but real arrays. Memory corruptions or unauthorized memory accesses
are impossible.
• Automatic garbage collection tracks objects usage over time.
Secure
• Usage in networked environments requires more security.
• Memory allocation model is a major defense.
• Access restrictions are forced (private, public).
DIFFERENCE BETWEEN C++ & JAVA

• Java is truly object oriented.


• Java does not support Operator Overloading.
• Java does not have template classes as in C++.
• Java does not support multiple inheritance of classes.
• But can be achieved by using interface.
• Java does not support global variables.
• Every variable and method is declared within a class and forms part of that class.
• Java does not use pointer.
OBJECT ORIENTED CONCEPTS WITH
RESPECT TO JAVA CLASS
• Class: A blueprint that defines the attributes and methods

• Object: An instance of a Class

• Abstraction: Hide certain details and show only essential details

• Encapsulation: Binding data and methods together

• Inheritance: Inherit the features of the superclass

• Polymorphism: One name having many forms


JAVA PROGRAMMING FUNDAMENTALS

• Structure of Java
• Program Data Types
• Variables
• Operators
• Keywords
GENERAL STRUCTURE OF JAVA PROGRAM
JAVA TOKENS

• Smallest Individual unit in Java Program is called as Java Tokens.

• Java includes five types of tokens


o Reserved Keywords
o Identifiers
o Literals
o Operators
o Separators
JAVA KEYWORDS
JAVA VARIABLES
Variables:
• Name
• Type
• Value
Naming:
• May contain numbers, underscore, dollar sign, or letters
• Can not start with number
• Can be any length
• Reserved keywords
• Case sensitive
DATA TYPES

• Primitive(built-in)

• Non Primitive(Derived)
 Arrays
 Classes
 Interface
DATA TYPES
OPERATOR TYPES

• Definition: An operator performs a particular operation on the operands it is applied on

• Types of operators:
 Assignment Operators
 Arithmetic Operators
 Unary Operators
 Equality Operators
 Relational Operators
 Conditional Operators
 Instance of Operator
 Bitwise Operators
 Shift Operators

You might also like