Monday, August 22, 2016

Basics of java for Android Development

If you dont have basics knowledge of any programming please do read about any of the programming language you can. this will give you a basic idea of how the programming flow. and after that read this blog. if you have already basic knowledge about java then good, you are good to go. just read these pages and you will good to go for android development.

 Java was developed in early 90s by sun micro-

system. And this is now owned by Oracle from Jan

27 2010.

 Java is cross platform programming language. It can

be run in Linux, windows, and mac as well. It runs in

a program compiler called JVM (java virtual

machine).

 Java is an object oriented programming language.

How it is different from c++

 Java does not support structure, unions and pointers

which are supported in c++.

 Java has automatic garbage collections, and does not

have the concept of destructors as in c++.

 Java has built-in support for thread but c++ has to

rely on third party lib for this functionality.

 There is no scope resolution operator (::) in java. But

c++ has it. In java method definitions must always

occur inside a class so there is no need for a scope

resolution operator.

 There is no goto statement in java. This is a constant

reserved but never used.

 Java in interpreted by JVM to machine level

language so this is platform independent.

Constructors

 Used to initialize the class and necessary variables.

This has no return type and called when the class is

referenced or instantiated.

Access modifiers

 Public

 Pirate

 Protected

 Default

Outer class can only have public, abstract and final.

Oops concept in java

Oops concept allows us to model software problems into a

real world entities and that makes it easy to solve the

problem.

 Programming techniques:

1. Unstructured programming (Cobol, Fortran)

2. Procedural programing (c, c++)

3. Object oriented programming (java)

-A procedural programming language is the ordinary

kind. It's one in which the programmer specifies a

sequence of steps and controls directly the order in which

they are performed. "First do this. Then, do that. Next,

either do this or that depending on something else.

-A unstructured programming language is similar to the

procedural but without any loops and entirely depends on

strict fields. It is an older language.

-A object oriented programming language depends on

data/object rather than the logic. Here objects are

created by combining properties of object and their

functions.

Object oriented programing features

1.abstraction

The purpose of abstraction is to hide information

that is not relevant or rather show only relevant

information and to simplify it by comparing it to

something similar in the real world.

2.encapsulation

This is the concept if information hiding. Here we

apply the concept of black box. Only those features. We

don’t know what the function does, but its internally

doing something to get the input and give us the output

we want.

By hiding implementation details, we can rework on

our method code at a later point of time, each time we

change out implementation this should not affect the

code which has a reference to our code, as our API still

remains the same.

3.Inheritance

The process by which one class acquires the

properties and functionalities of another class.

Inheritance provides the idea of reusability of code and

each sub class defines only those features that are

unique to it.

This is used in java by the keyword “extends”.

4.Polymorphism

Polymorphism is a feature that allows one interface

to be used for a general class of actions. It’s an operation

may exhibit different behavior in different instances. The

behavior depends on the types of data used in the

operation. It plays an important role in allowing objects

having different internal structures to share the same

external interface.

1. Function overriding.

2. Function overloading.

Types of inheritance

1. Single inheritance.

2. Multiple inheritance. (not used in java through class)

3. Multilevel inheritance.

4. Hierarchical inheritance.

5. Hybrid inheritance.

Interfaces and abstract class

An interface is a reference type in Java, it is similar to

class, it is a collection of abstract methods.

A class implements an interface, thereby inheriting the

abstract methods of the interface.

Abstract classes are classes that contain one or more

abstract methods.

An abstract method is a method that is declared, but

contains no implementation.

Abstract classes may not be instantiated, and require

subclasses to provide implementations for the abstract

methods.

You cannot make an instance of an abstract class but you

can extend it to another class and use it.

final