Thursday, August 7, 2014

                                               Interview Questions
Java
1. what are java class variables
    Class variables, however, only have one copy of the variable(s) shared with all instances of the class. 
    It’s important to remember that class variables are also known as static member variables
2. what is trasient varaible
    The keyword transient in Java used to indicate that the variable should not be serialized.
    By default all the variables in the object is converted to persistent state. In some cases, 
    you may want to avoid persisting some variables because you don’t have the necessity to transfer across the network.
    So, you can declare those variables as transient. - See more at: http://www.javabeat.net/what-is-transient-keyword-in-java/#sthash.QmB2rkKZ.dpuf
3. what are mutable and immutable objects
     Mutable objects have fields that can be changed, 
     immutable objects have no fields that can be changed after the object is created.
4. what are java primitive types
    byte,short,int,long,float,double,boolean,char
5. what is the min value of int and max value of int,long,float
6. what is sleep and wait
7. How many number of bits occupied by unicode, UTF8, UTF16, ACSII
8. Weak reference in java
     Strong,soft,weak,phantom
     soft -> reclaimed only if memory is low
     weak -> remclaimed immediately after all references of the object is null.
     Phantom -> 
9. Lazy loading; late binding - early binding
20.What is static class ? Why a outer class cannot be static ? What is static inner class ? how it is used ?
   Why cannot the non-static inner class cannot have a static members ?, also can it hold static final members ?
21. What is final class ? Why to make a class as final. ? In which design pattern we use final class.
22.Explanation of design patterns.mostly ( Singleton, Proxy, Adapter, Factory)
23. Can we Override static methods & can we overload static methods. ?
24. What is singleTon design pattern. Best way to use singleTon desing pattern in multithreaded environment
Approach 1:
      Class Singleton {
          public getInstance() {
              return Singleton.SingletonInner.inst;
          }

          static class SingletonInner {
              private static Singleton inst = new Singleton();
          }
Approach 2;
      Class Singleton {
            private static Singleton inst = new Singletion();
            public getInstance() {
                return inst;
            }
      }
Approach 3: 
      Class Singleton {
           private static Singleton inst = null;
           public getInstance() {
               if(inst == null) {
                    synchronized(getClass().object) {
                        if(inst == null) {
                             inst = new Singleton();
                         }
                     }
               }
               return inst;
           }
      }
25. Design patterns -> Adapter , Proxy, Observer, Factory
26. Why multiple inheritance not supported in Java.? and how
    multiple inheritance can be achieved in java.
27. What is Polymorphism explain with examples
28. Can a method be overloaded with return of the function.(NO)
     Methods can be overloaded only with the input parameters.
29. What is the difference between abstract class and interface ?
30. What is singleton pattern ? why it is used ? Instead of that 
    can't we use a static variable.
31. What is the difference btw abstract class and interface ?
Answer:
     1. abstract class
  we can declare variables inside it
    once extended by a child class, the child class cannot extend from another class
    can implement and define methods
     2. Interface 
    We can delare public static final variables
Once implemented by a chlid class, the child class can even implement from another interface
also can extend from another class.
Cannot define the methods.
32. Does hashmap maintain the order of  insertion ?
    What is the speciality of Hashmap over other maps? when to use this
    answer: use LinkedHashMap to preserve the order
33. write a linked list implementation
34. How hashing works in java?
35. To improve performance, declaring variables inside loop is good
    or outside the loop is  good.
36. What is the importance of the hashCode and equals  methods in object class.
      When we have to override them.



Android
10. What is ViewGroup when it is used.
11. How to communicate btw two application -> send data btw two applicaions and no other application
    cannot access that data.
     Two applications can sign with same singature (protectionLevel : Permission)
12. A->B start again activity A from B and the new instance of acitivity A should not be created.
13. Testing tool in Android && JUnit testing
           Robotium, selenium
14. tools in android, build tools in android (ANT)
17. ContentProvider
18. What is Cursor loader. When it is used. What are its methods.
19. What is Looper and MainLooper in android. When it is used ?
20. Adv and DisAdv of using IntentService and Service
21. How many times the view becomes null in getview() with a list size of 10 
    and at a time the view can display 5 items.
22. Explain android architecture ? which kernal version of linux android uses, content providers
    activity lifecycle,service lifecycle,android launch modes.
23. while using any decryption algorithms ? where do you store the key (which is used for encryption &
     decryption).
24. What is symmetric and assymetric encrypton/decryption alogithms.
Answer: Symmetric : AES ( for both encryption and decryption we use the same key)
        Assymetric: RSA  ( encryption is one key and decryption with another key).
25. We have developed an application in android which supports API level 19 . Now we
    want roll back to API level 6 ? How can we achieve this in our application with 
    minimal changes. Lets say we are using actionbar in latest but may not be supported
    in lower api level.
26. What is ActionBar Sherlock? what is the use of it.
27. When we are populating a listview by fetching data from n/w ? what is the best way
    to do keeping in mind the performance.
     Ex: In server there are 1000 entries; how do you show the data.
Answer: buffering mechanism
        lets say our listview initially shows 50 items at a time. now fetch 150 items
        from server and show first 50 ; Now if user scrolls down show next 50(which are in buffer) mean time
        fetch another 100 items
28. What is the difference between android sdk and android ndk; what is the usage of both
29. How to write JNI files? Why Jni files are required.
30. What are the techniques to parse the xml responses in Java. And which is more efficient? when to use which one?
     XmlPullParser, SAX parsers; XmlPullParser is more efficient
31. Different ways to connect to the internet resource ? And which is more efficient? when to use which one? 
      HttpClient, HttpUrlConnection
32. An application consists of an activity and service. activity, in its onStart starts the serivce and it never
    stops the service. Also the service never stops itself (stopSelf). Now if we pressback button tell weather
    the service stops and it will be running Explain with reason?
    (Note: service runs on main thread. when pressed back on activity main thread gets killed then how service
           is running ).
33. In which scenario,broadcast receiver can only be registered using manifest file and cannot be done through code. ?
like BOOT_COMPLETED and ALARM_MANAGER , we have to register only in Manifest file. BOOT_COMPLETED has to be in Manifest file bcz Since eventhough our application is  not in running mode the receiver class will be getting called.
34. What is SendOrderedBroadcast   ? When it should be used ? How to set prriority ? Is it serial or asynchronous ? how to abort it ?



Cloud(Sharepoint)
15. Polling, push-notification
     Server send sms via smsservers 
16. Why OAuth is required.

C++
1. What is virutal table and virutal pointer
2. What is diamond ring problem in c++
3. What is the static 


C
1. What is a static variable
2. Can a static variable declared inside a header file? will it be
    having different copies if used inside different files.
Answer: Yes, We can declare a static variable in a header file but the definition of the static variable 
        also needs to be in the same file. The source file(.cpp) files which includes the header file will have a 
        separate copy of the declared static variable which of course is not the intended purpose of declaring a static variable.
            However it is a bad idea of declaring a static variable in a header file. 
        While including the header file containing static variable we need to make sure the header file doesn't  
        get included more than once which shall cause the compiler to complain. 
        This can be achieved by putting our static variable in #ifndef and #endif block as mentioned  below.

   CODE SNIPPET
   ------------
        
ifndef __static_var_definitions__
#define __static_var_definitions__
static int varstatic;

#endif


3. 0x11223344 -> swap 11 and 44

4. int *p= <valid address> ; int a[] = {8,7,6,5,4}
    p = a; a = p ; -> both are valid or not ?
Answer: p = a; (Correct) ; a = p ( Compilation error - incompatable types int[], int*)
    Even though the array varible holds the address to the first element in the array, 
    it acts like as a constant pointer in that it cannot be changed. 
    It cannot be assigned a different array or a pointer to a different array. 
    Think about it, if you have a variable A that points to an array and you were able to change the address of A to something else, 
    what happens to the memory pointed to by the A array.
5. storage classes.
6. memory segments of a running program
    stack,data,heap,code(binary)

Programming
1. String reverse program
2. Check weather all the letters insdie one string matches with
   all the letters inside another string.
   Above 2 probs with min space and time complexity
3. Find the largest pattern in a given string
    Ex: abcpqrabcdpqrfabcdetrabcde
           The largest pattern in the above string is abcde
4. 3 boxes each contains Apples, oranges and Apples+ oragnes puzzle;
5. 8 queens problem in a chess ( implement a program, which retuns all possible chances)
6. Find equilibrium point in array and in a matrix ?
7. cities and routes problem
8. Delete a node in a single linked list(SSL) when given a single pointer.
9. Find the loop in  a SSL
10. Find the intersection point in a sLL

OS
1. What is deadlock
2. What are different IPC supported in linux
    Pipes, SharedMemory, Socket
3. Difference btw Mutex, semaphore and binary semaphore.
4. Difference between UDP and TCP


General
1. By the time you joined the team, you found that we cannot meet the deadlines
   you cannot hire team

                                                       Be patient, still this blog has to be properly edited and corrected. Atleast  you can check the questions.