Pages

Thursday, 23 April 2015

Explain Activity LifeCycle.

                                                    

1)onCreate()
                  Called when activity is first created.

2)onStart()
                   Called when Activity is visible to User.

3)onResume()
                     Called when activity will start interacting with user.

4)onPause()
                    Called when activity went to background but not be killed.

5)onStop()
                   Called when activity UI is not visisble to user.

6)onRestart()
                    Called activity  started again.

7)onDestroy()
                  Called before activity is destroyed.

Activity vs Fragment

Activity

1)Should have UI
2)Ability to retainState across Configuration Changed by using onRestoreInstanceState() and onSaveInstanceState().


Fragment(Introduced on 3.0)

1)Can have UI/NO UI.
2)Ability to retainState across Configuration Changed by using setRetainInstance(true).
3)ReUsability of UI
4)Tricky to handel back button.

Diffrence between service and intentServcie

Service 

1)Used to do the task in background
2)dont have UI
3)starts with main Thread.

Demerits:
 If we do long running task in background the ANR will occour,
To avoid this we have to use thread to do long running task in background
So to fulfill the above requirement we have intent service which provide worker Thread to do long running task in background.

IntentService

Its a extension of service which enable to do long running task in background

Diffrence between thread,asynchTask and service

Thread

1)Process in execution is called Thread.
2)We can create thread by using Extending Thread or Implementing Runnable.
3)Thread ,we can use if we don't want UI mainly(Otherwise if you want then you have to use Handler to update UI).

AsynchTask

1)Enable proper and easy use of UI thread.
2)It mainly used to update the UI when task has been completed.
3)It can be achieve by using the methods available in AsynchTask.


Service

1)It mainly used to do the task in background.
2)don't have UI.
3)Always starts from main thread.

Tell something about AsynchTask?

AsynchTask

1)It enable proper and easy use of UI thread.
2)It does the work in background and give the result on UI thread without use of Handler.
3)It has 4 stages
        i)onPreExecute()
                              Invoked before the task executed.
                              Runs in mainThread,

        ii)doInBackground()
                          Invoked in background to perform the task.
                          Runs in backgroundThread,

        iii)onProgressUpdate()
                          Invoked to update the progress UI after the call of onPublishProgress() in                                             doInBackground().

                          Runs in mainThread,
           
        iv)onPostExecute()
                        Invoked to update the UI finally
                        Runs in mainThread,

Diffrence between Thread and Asynch task?

Thread

1)Process in execution is called Thread.
2)We can create thread by using Extending Thread or Implementing Runnable.
3)Thread ,we can use if we don't want UI mainly(Otherwise if you want then you have to use Handler to update UI).

AsynchTask

1)Enable proper and easy use of UI thread.
2)It mainly used to update the UI when task has been completed.
3)It can be achieve by using the methods available in AsynchTask.

                                  

Monday, 16 June 2014

Difference Between String and StringBuilder




String

String Builder 

1. String is Immutable type.

1. StringBuilder is mutable type.
2. Existing object cannot be modified rather creates new object in the String pool. 

2. Existing object can be modified and and doesn't create any new object in heap. 
3. String is Thread Safe.

3. StringBuilder is not Thread Safe.

4. Many Unused object left to be garbage collected if many String object are modified. 

4. Unused objects are not left to be garbage collected.

Tuesday, 8 April 2014

Difference between Construct and Setter Injection



Constructor Injection 

Setter Injection 

1. Injecting bean properties through argumented constructor.

1.Injecting bean properties through setter method.
2. It will first inject the bean dependencies then create the instance of current bean.

2. It will first create the bean instance and then inject the bean dependencies.

3. Chance of forming Cyclic Dependency

3. No chance of Cyclic Dependency.


4. In case of Auto-wiring it can done with "construtor autowiring process ".

4. It can be possible with two autowiring concept ,
    a. byName                b. byType

5. No chance of getting UnsatisfiedDependencyExeption.

5. UnsatisfiedDependencyException in case of byType autowiring. 

6. In case of Explicit Wiring,
<constructor-arg/> tag is use to define this injection. 
6. <property/> tag s used to define this injection

7. In Cyclic Dependency , only one bean will be injecting by ignoring cyclic dependency. 
7. Doesn't form Cyclic Dependency, so both the bean will be injected successfully.

Saturday, 5 April 2014

Difference between Explicit and Auto Wiring in the Spring




Explicit Wiring 

Auto Wiring

1. Explicit Wiring means hard-coding the dependencies in the XML.

1. Not hard-coding in the XML file rather Container to detect and inject Dependencies.
2. Mainly it can be done in two ways
    a. Constructor   b. Setter injection 
2. It can be done in four ways 
a. byName     b. byType
c. constructor  d. autodetect
3. It requires writing more content in the XML which ultimately makes XML little complex.  
3. It doesn't require much writing rather need just any of the four value to the autowire attribute. 

Thursday, 3 April 2014

Difference Between SOAP and REST WebServices




SOAP WebServices 

REST WebServices

1. SOAP stands for Simple Object Access Protocol.

1.REST stands for REpresentational  State Transfer
2.  It is the concept which uses SOAP libraries both at client and Server side. 
2. It is the concept uses HTTP Specification for request and response.
3. In this, client sends a SOAP document(XML document) as a request to the WebServices.
3. In this,  client sends request as a  HTTP request to the WebServices.
4. WebService sends a SOAP document as a response to the client. 
4. WebService sends a XML document as a response to the client.
5. It implements SOAP library for communication. 
5. It does not uses any library for communication, use HTTP as a message resource.  
6. It is little complex to implement as compared to REST.
6. It is easier to implement. 
7. SOAP document is WSDL (Web
Services Definition language ) which is formally a XML document. 
7.It uses HTTP GET as a request to
read the WebService and POST as to CREATE a new resource from the requested data.
8.  " @WebService " annotation is
used at the SEI (Service Endpoint Interface)  and SIB ( Service Implementation Bean )
8. " @WebServiceProvider " is used in the service class and implements Provider interface.  

Tuesday, 11 March 2014

Angular JS Features.

  1. Controller
    • It is just a java script function.
    • It contains data.
    • It specifies the behavior.
    • It should contain only the business logic needed for a single view.
  2. Scope
    • An object that refer to the application model
    • An execution context for expression like {{animal.property}}
    • Scopes are arranged in hierarchical structure which mimic the DOM structure of the application.
    • Scopes can watch expressions and propagate events.
     
  3.  Model
    • It is just a java script object.
    • Model represent an object with some key and value.
  4. View
    • View is nothing but just the HTML.
  5. Services
    • Services in Angular JS are singleton.
    • It is used to perform the common task between the controllers.
    • We can access the common task between the controllers using services.
    • Angular JS have some built in services that start with a symbol $.
  6. Directives
    • Directives are used to remove the code duplication.
    • You can define you your own directive and use that according to your requirement.
    • 'ng' prefix in Angular JS stands for built in directives like ng-app, ng-model etc.
  7. Filters
    • It is used to filter the result according to user requirements.
    • You can also format your result using filters.
  8. Routing
    • It is used to configure the navigations.
    • You can go from one page to another using routing.

Best IDE For Angular JS

Many peoples working on Angular JS want some best IDE which support Angular JS. I was also searching for the IDE which support Angular JS. After a lot of searching i came across Jet Brain Webstrome and Intellij Idea . These two IDE support Angular JS and performs best of all others. Specially if you want to work on client side web application Jet BrainsWebstrome is best to work with.
Good Luck

Angular JS Interview Questions.

Here is some of the interview questions which you might be looking for then must must go through all .
For the answers and for more questions you can refer this link Angular JS Interview Questions You can ask you question there.
  1. Difference between Angular JS and JQUERY ?
  2. What are the key features of Angular JS ?
  3. How can you define scope in Angular JS ?
  4. What is controller in Angular JS ?
  5. What is Model in Angular JS ?
  6. What is view in Angular JS ?
  7. What is Services in Angular JS ?
  8. What is data binding in Angular JS ?
  9. What is directives in Angular JS ?
  10. What is Filter in angular JS ?
  11. How can you perform Validation in Angular JS ?
  12. How can you test your code in Angular JS ?
  13. How can you perform Routing in Angular JS ?
  14. How can you compare Angular JS with Backbone JS ?
  15. How will you loops through a collection and List in Angular JS ?
  16. How will you parse a JSON response in Angular JS ?

Monday, 9 December 2013

Difference between using Context Object and Request Object with the RequestDispatcher




Context Object with RequestDispatcher

Request Object With RequestDispatcher 

1. Using Context object with the getRequestDispatcher() its mandatory to write url starting with " / " .

1. Using Request object with the getRequestDispatcher(), its not mandatory to use " / " before url. 
2. It uses the context path of the URI

2. It uses the context path if we write
" / " before url and if we are not writing " / " then the request will be forwarded using relative path.

3. If we are not writing " / " before
 url then container will throw IllegalArgumentException exception " This given path is invalid, since it doesn't start with  / " . 

3. If we are not writing " / " before url then it forward the request using relative path.

4. For ex-

RequestDispatcher   rd = getServletContext().
getRequestDispatcher("/url");

4. For ex-

RequestDispatcher   rd = getServletContext().
getRequestDispatcher("/url");

                     or

RequestDispatcher   rd = getServletContext().
getRequestDispatcher("url") ;

Tuesday, 3 December 2013

Difference between Shallow and Deep Cloning



Shallow Cloning 

Deep Cloning 

1. It is a default cloning and can be done by using clone() method.

1.It is done by the user itself by writing the code for the deep cloning.
2. Shallow cloning fails to clone object members. 

2. Using deep cloning we can able to clone object member also .

Monday, 2 December 2013

Difference between include and forward of RequestDispatcher in Servlet




include()  

forward()

1. It is used to include the response to the source servlet.

1. It is used to forward the request to the other servlet or JSP page.  
2. Response get committed after including all other resources(servlet/JSP) responses.  
2. Response get committed by the RequestDispatcher object and also close the response stream. 
3. A servlet class can have multiple include statement to execute. 
3. A servlet class can have multiple forward statement conditionally but will execute only one.  
4. After executing include() control will back to the source servlet and will add information to response object. 
4. After executing forward() control will
back to the source servlet but other informations cannot be added to that response object.

Wednesday, 27 November 2013

Difference between Static and dynamic polymorphism



Static Polymorphism 

Dynamic Polymorphism 

1. It is otherwise called as compiler-time polymorphism.

1.It is otherwise called as run-time polymorphism.
2. Overloading is used to achieve this.

2.Both overriding and dynamic dispatch is used to achieve this.

3. It is also called as static binding as compiler is binding the method with the object based on the argument.

3. It is called as dynamic binding as JVM will decide from which class the method will be executed based on the object assign.


4.Static method can be overloaded.

4. Static method never follow dynamic dispatch concept. 

5. All works are done at the compilation time by the compiler that's why called as static binding.

5. All works are done at the run-time by the JVM that's why called as dynamic binding.

6. It is achieved by the compiler at the compile time.

5. It is achieved by the JVM at the run-time.

Tuesday, 26 November 2013

Difference between Abstract class and interface in Java





Abstract class  

Interface

1.  A class become abstract when we use ' abstract ' keyword before the class name.

1. No need of using any abstract keyword but we need to use ' interface ' keyword. 

2. We can use instance variable.

2. We cannot use any instance variable.
3. Can define static/ non-static variable.

3. Variables are by-default static.

4. Can use static/ non-static method

4. Static and non-static both cannot be used.

5. Can use private and protected with the variable 

5.  Cannot use private and protected with the variable.

6. Static and instance both initialization block are allowed. 

6. Both static and instance initialization block are not allowed.

7. Constructor are used to initialize instance variable defined in abstract class. 

7. Cannot define constructor in an interface.

8.Cannot be used for achieving multiple inheritance. 

8. It is used to achieve multiple inheritance in java.

9. Can define final and non-final method but final method should not be abstract. 

9. Cannot define final and non-final method.

10. Can define abstract and non-abstract method in an abstract class. 

10.Cannot define non-abstract method and by-default method are abstract.

11.' extends ' keywords are used to extend abstract class. 

11.' implements ' keyword are used to implement any interface.

12. It extends java.lang.Object class.

12.It cannot extend java.lang.Object class.

13. Can define main method in an abstract class. 

13.Cannot define main method in an interface.

14. Instance ' inner class ' is allowed inside as abstract class. 

14. Instance inner class in not allowed and will be converted into static inner class by compiler.

Friday, 22 November 2013

Difference between Primitive type and Reference type in Java



Primitive type  

Reference type

1. It is predefined in any programming language.

1.It is predefined as well as user-defined in Object oriented language.
2. It is used to store value may be integer, decimal , floating or boolean.

2.It is used to store the reference value of the object and is of integer type.

3.Size of the primitive type are varies according to the type. 

3. Reference type has fixed size of 8 Byte.


4.It doesn't point to any object as it simply stores the required value.

4. It always points to the
corresponding object whose address is stored as a reference value. 

5. int, float,char,short,byte etc are the example of primitive type
5. String, Array,Class, interface are the examples of reference type.

Saturday, 16 November 2013

What are the differences between public and private access modifier in java




Public access modifier  
Private access modifier

It is uses the public keyword in java .

It uses the private keyword in java.

Member defined using public is visible ANYWHERE.

Member defined using private is only visible to that class only

Public can be used with class.

Private cannot be used with the class

We can make an interface as public.

We cannot make an interface as private.