JAVA AND OOPS CONCEPTS.pptx helpful for engineering

PriyanshuGupta101797 29 views 35 slides Jul 21, 2024
Slide 1
Slide 1 of 35
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24
Slide 25
25
Slide 26
26
Slide 27
27
Slide 28
28
Slide 29
29
Slide 30
30
Slide 31
31
Slide 32
32
Slide 33
33
Slide 34
34
Slide 35
35

About This Presentation

Java and oops concepts


Slide Content

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: F or 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…
Tags