Android java interview question for 2 year experience

Hi guys, In this articles, we learn about Android java interview question for 2-year experience

1. Tell me about OOPs concept.

We see the following image to understand the Object-Oriented Programming concept:

  1. Object
  2. Method
  3. Polymorphism
  4. Inheritance
  5. Encapsulation
  6. Abstraction

We will learn the OOPs concept in more detail in another article.


2. What is the difference between Activity Context and Application Context

Firstly they both are instances of Context, But Instance of Application context tied with the life cycle of Application it gives the context of the entire application while Activity Context tied with the life cycle of Activity if Activity destroys then the instance of activity context also destroy.

To get Application context use  getApplicationContext() method and to get Activity context use “this” keyword.


3. What is an abstract class?

A class contain at least one abstract method is called abstract class, the abstract method is a method which does not have any implementation it just have the signature, consider the following example:

By using abstract class we can achieve abstraction, this is one of the OOPs concepts which means showing functionality by hiding implementation details that are known as abstraction, we can reuse the same class for multiple

Can abstract class have a constructor?

Yes, you can define a constructor and also pass parameter

Can we overload abstract class?

Yes, you can overload it.


4. Do you know multilevel inheritance?

In java, one class can get feature from another class, this mechanism is known as inheritance, there are three types of inheritance. 1. Simple inheritance, 2. Multilevel inheritance, 3. hierarchical inheritance

Example of multilevel inheritance:


5. What is service? How to use services?

Services is a component that’s run in the background usually used for long term processes like playing music, it is not attached with the life cycle of Application so even if the application will destroy, services will not destroy it has two state

Started: Service is started with the component of application gets start like activity, service will start and runs still indefinitely, it will start by calling startService();

Bound: Service is bound when the component of application get binds, it will bind by calling bindService(); Bound service offers a client-server interface that allows UI components to interact with the background services like send request, get the result, we can allow to carry out (IPC) interprocess communication

below is the life cycle method of services:

  1. onStartCommand();
  2. onCreate();
  3. onBind();
  4. onUnbind();
  5. onRebind();
  6. onDestory();

I will write a new article fro services life cycle as soon as possible


6. What is AsyncTask in Android?

Android handles all event and task with a single user interface called as the main UI thread, and this Main thread cannot handle the same type of operations at the same time, to carry out we have to use AsyncTask, it is an abstract class which helps Application to handle multiple concurrent operations in the main thread, it can perform a long time processes or tasks and background operations without affecting main thread. This is carried out using four steps:

  1. onPreExecute() – This method usually called before main doInBackground, we can set up task init task like show the progress bar.
  2. doInBackground() – Main logic code which runs for a long time will put inside this method.
  3. onProgressUpdate() – This method display progress of our process which we can display on the main UI interface.
  4. onPostExecute() – Result of doInBackground will passed to this method after task complete.

Example of asyncTask

We have to pass the parameter to asyncTask like below:

These are some of the important questions, I will write another article for remaining Android java interview question for 2-year experience, stay connected Thank you 🙂

For more questions check this post

 

 

2 Replies to “Android java interview question for 2 year experience”

  1. What’s Taking place i am new to this, I stumbled upon this I’ve found It positively
    useful and it has helped me out loads. I am hoping to give
    a contribution & aid other users like its helped me. Great job.

Leave a Reply

Your email address will not be published. Required fields are marked *