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

Introduction To Android Development - OOPS

The document discusses object-oriented programming concepts like classes, objects, methods, access modifiers, inheritance, polymorphism, and composition. Key points include: - Classes represent objects and their properties/behaviors. We create object instances using new. - Methods define reusable code and can have access modifiers like public or private. - Inheritance allows subclasses to extend parent classes using extends. The subclass inherits properties and behaviors. - Polymorphism allows the same method to behave differently based on input arguments or subclass overrides. - Composition allows classes to utilize other classes as properties, like an Engine class being used in a Car class.

Uploaded by

hareesh.cse21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Introduction To Android Development - OOPS

The document discusses object-oriented programming concepts like classes, objects, methods, access modifiers, inheritance, polymorphism, and composition. Key points include: - Classes represent objects and their properties/behaviors. We create object instances using new. - Methods define reusable code and can have access modifiers like public or private. - Inheritance allows subclasses to extend parent classes using extends. The subclass inherits properties and behaviors. - Polymorphism allows the same method to behave differently based on input arguments or subclass overrides. - Composition allows classes to utilize other classes as properties, like an Engine class being used in a Car class.

Uploaded by

hareesh.cse21
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 19

Object Oriented Programming.

Part - 1
 The core Component in oops is classes
source → package sight click → New Java class
 class: keyword to make class
 Class represent a object
 for the class we need to make instance
Syntax: Class_Name obj_Name = new Class_Name()
 we can access the properties of that class by obj_Name.

Main class

Another class:

We can access the class ‘Phone’ by creating a object for the class.
 method
↳ method have name,
↳ every Method have a name
↳ There is inputs in method
↳ void: no return.
↳ Method is used to reuse and organizing the code
↳ Private: using private method only the class can access no outside
class can access the method.
↳ Access modifiers,
 public: accessible to all class.
 private: only accessible by inside a class. Private use only inside of
the classes. Not given for class.
 Protected

↳ By making method we can access a protected Property

↳ If we want to change

↳ If we want to get
use in main

↳ By IDE we can do this


Right click ➔ Generate ➔ getter and setter ➔ select ➔ OK
↳ Right click ➔ Generate ➔ constructor
 same as class name.
Part - 2
 make a class Dog

 make getter and setters.


 make a class Bird.
 Inside package Create a animal class

 delete every thing in Bird


 Do it to Dog Class
 Extends: In Java, the extends keyword is used to indicate that the class
which is being defined is derived from the base class using
inheritance. So basically, extends keyword is used to extend the
functionality of the parent class to the subclass.
 Super: The super keyword refers to superclass (parent) objects. It is
used to call superclass methods, and to access the superclass constructor.
The most common use of the super keyword is to eliminate the confusion
between superclasses and subclasses that have methods with the same
name.- setion to Bird and a
 Return to Bird and add a protected object wings to Bird
 and redo that making constructor we can also make getter and setter to
wings
 calling the method in main
 Override eat method.(ctrl+o)

 by deleting the caper keyword you Can completely change the behavior of
The method.
 We can give same method with different parameters

 while we constructing a class extends dog the dog's parent class. will be
inherited

Polymorphism
 If we have another contractor in class it is called polymorphism -> having
multiple forms.
 Before, The eat method behave Differently it is another kind of
Polymorphism.
 same method with different input arguments.
Part – 3 (composition)
 In package create a new class Engine
 we can use it as a type
Engine use in main
1.

2.
 Keywords
↳ final :The value won't change we cannot change value.
↳null

 but can change properties.

Challenge
Q. Doctor consultation application as the given model.
Sol:

add getDetails method

You might also like