Android Flashcards
(36 cards)
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
android spp components
An activity represents a single screen with a user interface,in-short Activity performs actions on the screen
A service is a component that runs in the background to perform long-running operations.
Broadcast Receivers simply respond to broadcast messages from other applications or from the system.
A content provider component supplies data from one application to others on request. Such requests are handled by the methods of the ContentResolver class
context
An Android Context is an Interface (in the general sense, not in the Java sense; in Java, Context is actually an abstract class!) that allows access to application specific resources and class and information about application environment.
AndroidManifest.xml
The AndroidManifest.xml file contains information of your package, including components of the application
Application class
The Application class in Android is the base class within an Android app that contains all other components such as activities and services
diff activity and fragments
Activity is an application component which give user interface where user can interect. Fragment is a part of an activity,which contibute its own UI to that activity.
Activity is not dependent on fragment.but Fragment is dependent on Activity,it can’t exist independentaly.
Communicate with other fragments
getSupportFragmentManager().findFragmentById(R.id.article_fragment);
View
View objects are the basic building blocks of User Interface(UI) elements in Android.
View is a simple rectangle box which responds to the user’s actions.
Examples are EditText, Button, CheckBox etc..
View refers to the android.view.View class, which is the base class of all UI classes.
ViewGroup
ViewGroup is the invisible container. It holds View and ViewGroup
For example, LinearLayout is the ViewGroup that contains Button(View), and other Layouts also.
ViewGroup is the base class for Layouts
custom view
For drawing view use the onDraw() method. In this method you receive a Canvas object which allows you to perform drawing operations on it