Android Flashcards
OOP Concepts.
Object-Oriented Programming is a methodology of designing a program using classes, objects, inheritance, polymorphism, abstraction, and encapsulation
Inheritance
defined as deriving new classes (sub classes) from existing ones (super class or base class) and forming them into a hierarchy of classes.an object created through inheritance (a “child object”) acquires all the properties and behaviors of the parent object (except: constructors, destructor, overloaded operators and friend functions of the base class)
polymorphism
the use of a single symbol to represent multiple different types.
Abstraction
only the general states and behaviors are taken and more specific states and behaviors are left aside for the implementers
Encapsulation
Encapsulation is an OOPS concept to create and define the permissions and restrictions of an object and its member variables and methods
constructor
A constructor is a method used to initialize the state of an object, and it gets invoked at the time of object creation. Constructor Name should be same as class name. A constructor must have no return type.
destructor
A destructor is a method which is automatically called when the object is made of scope or destroyed. Destructor name is also same as class name but with the tilde symbol before the name.
Function overloading
Function overloading an as a normal function, but it can perform different tasks. It allows the creation of several methods with the same name which differ from each other by the type of input and output of the function.
types of arguments
Call by Value – Value passed will get modified only inside the function, and it returns the same value whatever it is passed it into the function.
Call by Reference – Value passed will get modified in both inside and outside the functions and it returns the same or different value.
ternary operator
?: is a ternary operator that is part of the syntax for basic conditional expressions in several programming languages.
super
a reference variable which is used to refer immediate parent class object,method or constructor
interface
It is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.
Difference between overloading and overriding
Overloading is nothing but the same method with different arguments, and it may or may not return the same value in the same class itself.
Overriding is the same method names with same arguments and return types associated with the class and its child class.
THIS
THIS pointer refers to the current object of a class. THIS keyword is used as a pointer which differentiates between the current object with the global object
Static polymorphism and Dynamic polymorphism
Static polymorphism in Java is achieved by method overloading
Dynamic polymorphism in Java is achieved by method overriding