Thanks to visit codestin.com
Credit goes to www.slideshare.net

JAVA AND OOPS
CONCEPTS
(SUB CODE: CSE-S204)
NAME: PRIYANSHU GUPTA
ROLL NO: 055
BRANCH: CSE
INTRODUCTION AND KEY FEATURES:
(1.)Java is a high-level, class-based, object-oriented programming language.
(2.) Design goal of allowing application developers to "write once, run anywhere" (WORA),
meaning compiled Java code can run on all platforms that support Java without the need for
recompilation.
FEATURES:
. Platform Independent
. Object- Oriented
. Performance: Just –In Time Compilation
. Garbage Collection
Java Virtual Machine (JVM)
 The JVM is an integral part of the Java programming ecosystem , serving as a
virtual platform that executes Java bytecode. This bytecode is a form of
intermediate representation of Java programs , which is generated after compiling
java source code.
 The JVM enables Java programs to run on implementation , thereby providing
Java with its hallmark feature of ‘ write once, run anywhere.’
 Its abstracts away the complexities of the underlying hardware and operating
systems, managing memory allocation, garbage collection, and proving a secure
execution environment, making it easier for developers to build portable and
efficient Java applications without worrying about platform – specific details.
JAVA RUNTIME ENVIRONMENT (JRE)
 The Java Runtime Environment (JRE) is a part of the Java Development Kit (JDK)
that provides the libraries , the Java Virtual Machine(JVM), and other components
necessary for running applications written in Java programming language.
 It acts as a runtime platform, ensuring that Java applications can execute on any
device with the JRE installed, regardless of the underlying hardware and operating
system. This makes Java applications portable and cross-platform meaning they
can run on any device that has the JRE installed.
Java Development Kit (JDK)
 The JDK is a comprehensive toolkit for developers who want to develop Java
applications. It includes the JRE , which provides the libraries and the JVM , as well
as the wide array of development tools such as compiler , documentation
generator and more. The JDK enables developers to write , compile and debug
Java code and build applications .
 It serves as a foundation for Java development allowing for the creation of robust,
high performance Java applications that can run on any platform with a
compatible JVM.
Java Keywords
Variables :
 Variables are the named storage locations.
DATATYPES IN JAVA:
OPERATORS IN JAVA:
 Arithmetic Operator (+ ,- ,* ,/ ,%)
 Relational Operator (> , < , >= , <= , == , != )
 Logical Operator (&& , || , ! )
 Bitwise Operator ( & , | , ^ , << , >> )
 Assignment Operator ( = , += , -= , *= , /= , %= )
 Unary Increment / Decrement Operator (++ , -- )
Taking Input In Java:
Java Garbage Collector :
 The Java Garbage Collector (GC) is an automatic memory management system
the frees up the memory by reclaiming space occupied by the objects that are no
longer in use by a program.
 In Java , objects are dynamically allocated on the heap, and over time, some
objects may no longer be reachable or needed by the application.
 The garbage collector identifies these “garbage” objects and deletes them to
make room for new objects , thus preventing memory leaks and ensuring efficient
use of memory.
Java Conditionals:
 If statement
 If – else statement
 Ternary Operator
 Nested If – else statement
 If - else if – else ladder
 Switch Statement
Loops In Java:
 For Loop:
 While Loop:
 Do – while Loop:
 For – each Loop
Methods In Java :
 A method is a block of code that performs a specific task.
 Function Declaration:
 Function Call :
Return Keyword and Method Parameters:
 Return Keyword:
 Method Parameter:
Arrays In Java :
 In Java , an array is a container object that holds a fixed number of values of a
single type . The length of an array is established when the array is created , and
it cannot be changed once created . Each item in an array is called an element ,
and each element is accessed by its numerical index.
 Creation of array:
 Declaration
 Allocation
 Initialization
For – each Loop:
Multi – Dimensional Array:
 In Java , a multi – dimensional array is essentially an array of arrays. The most
common type of multi – dimensional array is the two – dimensional array , which
can be thought of as grid or table of rows and columns . However , java supports
arrays of any number of dimensions.
Strings in Java :
 In Java , a string is a sequence of characters used to store and manipulates text. It
is one of the most fundamental data types in Java and is part of java . lang
package, which is automatically imported into every Java program.
 Creation of String :
 String Keyword: string str = “Priyanshu” ;
 New Keyword : String name = new String (“Priyanshu”);
 Strings in Java are immutable , which means once a string object is created , its
value cannot be changed. If you perform any operations that seem to modify a
String , what actually happens is a new string object is created .
String Pool and Java String Methods:
 String Pool: Java maintains a special area in the Java heap called the string
pool. This is where all string literals are stored . When you create a string using
string literals , Java checks the pool first . If it already exists , it returns the
reference to the same instance , helping to save memory.
 Java String Methods:
 .length( )
 .charAt ( int index )
 .substring( int beginIndex , int endIndex )
 .contains( CharSequence s )
Java Exception Handling:
 In Java , exception is an unwanted or unexpected event , which occurs during the
execution of a program , i.e, at runtime, that disrupts the normal flow of
program’s instructions. Exceptions can be caught and handles by the program.
 Exception occurs due to:
 Invalid user input
 Device failure
 Code errors
 Opening an unavailable file
 Loss of network connection
Runtime Exceptions and IO Exception:
Try – Catch Block:
 The try statement allows you to define a block of code to be tested for errors
while it is being executed.
 The catch statement allows you to define a block of code to be executed , if an
error occurs in the try block.
Try – catch – finally Block:
Throws Keyword:
 We use the throws keyword in the method declaration to declare the type of
exceptions that might occur within it .
 Its syntax is :
Throw Keyword:
 The throw keyword is used to explicitly throw a single exception. When an
exception is thrown , the flow of program execution transfers from the try block
to the catch block . We use the throw keyword within a method.
 Its syntax is :
OOPS:
Encapsulation:
Inheritance:
Types Of Inheritance:
Polymorphism:
Static Polymorphism:
 Method Overloading
 Operator Overloading
Abstract Class vs Interface:
Thank YOU…

JAVA AND OOPS CONCEPTS.pptx helpful for engineering

  • 1.
    JAVA AND OOPS CONCEPTS (SUBCODE: CSE-S204) NAME: PRIYANSHU GUPTA ROLL NO: 055 BRANCH: CSE
  • 2.
    INTRODUCTION AND KEYFEATURES: (1.)Java is a high-level, class-based, object-oriented programming language. (2.) Design goal of allowing application developers to "write once, run anywhere" (WORA), meaning compiled Java code can run on all platforms that support Java without the need for recompilation. FEATURES: . Platform Independent . Object- Oriented . Performance: Just –In Time Compilation . Garbage Collection
  • 3.
    Java Virtual Machine(JVM)  The JVM is an integral part of the Java programming ecosystem , serving as a virtual platform that executes Java bytecode. This bytecode is a form of intermediate representation of Java programs , which is generated after compiling java source code.  The JVM enables Java programs to run on implementation , thereby providing Java with its hallmark feature of ‘ write once, run anywhere.’  Its abstracts away the complexities of the underlying hardware and operating systems, managing memory allocation, garbage collection, and proving a secure execution environment, making it easier for developers to build portable and efficient Java applications without worrying about platform – specific details.
  • 4.
    JAVA RUNTIME ENVIRONMENT(JRE)  The Java Runtime Environment (JRE) is a part of the Java Development Kit (JDK) that provides the libraries , the Java Virtual Machine(JVM), and other components necessary for running applications written in Java programming language.  It acts as a runtime platform, ensuring that Java applications can execute on any device with the JRE installed, regardless of the underlying hardware and operating system. This makes Java applications portable and cross-platform meaning they can run on any device that has the JRE installed.
  • 5.
    Java Development Kit(JDK)  The JDK is a comprehensive toolkit for developers who want to develop Java applications. It includes the JRE , which provides the libraries and the JVM , as well as the wide array of development tools such as compiler , documentation generator and more. The JDK enables developers to write , compile and debug Java code and build applications .  It serves as a foundation for Java development allowing for the creation of robust, high performance Java applications that can run on any platform with a compatible JVM.
  • 6.
  • 7.
    Variables :  Variablesare the named storage locations.
  • 8.
  • 9.
    OPERATORS IN JAVA: Arithmetic Operator (+ ,- ,* ,/ ,%)  Relational Operator (> , < , >= , <= , == , != )  Logical Operator (&& , || , ! )  Bitwise Operator ( & , | , ^ , << , >> )  Assignment Operator ( = , += , -= , *= , /= , %= )  Unary Increment / Decrement Operator (++ , -- )
  • 10.
  • 11.
    Java Garbage Collector:  The Java Garbage Collector (GC) is an automatic memory management system the frees up the memory by reclaiming space occupied by the objects that are no longer in use by a program.  In Java , objects are dynamically allocated on the heap, and over time, some objects may no longer be reachable or needed by the application.  The garbage collector identifies these “garbage” objects and deletes them to make room for new objects , thus preventing memory leaks and ensuring efficient use of memory.
  • 12.
    Java Conditionals:  Ifstatement  If – else statement  Ternary Operator  Nested If – else statement  If - else if – else ladder  Switch Statement
  • 13.
    Loops In Java: For Loop:  While Loop:  Do – while Loop:  For – each Loop
  • 14.
    Methods In Java:  A method is a block of code that performs a specific task.  Function Declaration:  Function Call :
  • 15.
    Return Keyword andMethod Parameters:  Return Keyword:  Method Parameter:
  • 16.
    Arrays In Java:  In Java , an array is a container object that holds a fixed number of values of a single type . The length of an array is established when the array is created , and it cannot be changed once created . Each item in an array is called an element , and each element is accessed by its numerical index.  Creation of array:  Declaration  Allocation  Initialization
  • 17.
  • 18.
    Multi – DimensionalArray:  In Java , a multi – dimensional array is essentially an array of arrays. The most common type of multi – dimensional array is the two – dimensional array , which can be thought of as grid or table of rows and columns . However , java supports arrays of any number of dimensions.
  • 19.
    Strings in Java:  In Java , a string is a sequence of characters used to store and manipulates text. It is one of the most fundamental data types in Java and is part of java . lang package, which is automatically imported into every Java program.  Creation of String :  String Keyword: string str = “Priyanshu” ;  New Keyword : String name = new String (“Priyanshu”);  Strings in Java are immutable , which means once a string object is created , its value cannot be changed. If you perform any operations that seem to modify a String , what actually happens is a new string object is created .
  • 20.
    String Pool andJava String Methods:  String Pool: Java maintains a special area in the Java heap called the string pool. This is where all string literals are stored . When you create a string using string literals , Java checks the pool first . If it already exists , it returns the reference to the same instance , helping to save memory.  Java String Methods:  .length( )  .charAt ( int index )  .substring( int beginIndex , int endIndex )  .contains( CharSequence s )
  • 21.
    Java Exception Handling: In Java , exception is an unwanted or unexpected event , which occurs during the execution of a program , i.e, at runtime, that disrupts the normal flow of program’s instructions. Exceptions can be caught and handles by the program.  Exception occurs due to:  Invalid user input  Device failure  Code errors  Opening an unavailable file  Loss of network connection
  • 22.
  • 23.
    Try – CatchBlock:  The try statement allows you to define a block of code to be tested for errors while it is being executed.  The catch statement allows you to define a block of code to be executed , if an error occurs in the try block.
  • 24.
    Try – catch– finally Block:
  • 25.
    Throws Keyword:  Weuse the throws keyword in the method declaration to declare the type of exceptions that might occur within it .  Its syntax is :
  • 26.
    Throw Keyword:  Thethrow keyword is used to explicitly throw a single exception. When an exception is thrown , the flow of program execution transfers from the try block to the catch block . We use the throw keyword within a method.  Its syntax is :
  • 27.
  • 28.
  • 29.
  • 31.
  • 32.
  • 33.
    Static Polymorphism:  MethodOverloading  Operator Overloading
  • 34.
  • 35.