Thursday 18 October 2012

OOPS Interview Questions and Answers (part 1)



1) What is meant by Object Oriented Programming? 
     OOP is a method of programming in which programs are organised as cooperative collections of objects. Each object is an instance of a class and each class belong to a hierarchy.

2) What is a Class? 
     Class is a template for a set of objects that share a common structure and a common behaviour.

3) What is an Object? 
     Object is an instance of a class. It has state,behaviour and identity. It is also called as an instance of a class.

4) What is an Instance? 
     An instance has state, behavior and identity. The structure and behavior of similar classes are defined in their common class. An instance is also called as an object.

5) What are the core OOP’s concepts? 
     Abstraction, Encapsulation,Inheritance and Polymorphism are the core OOP’s concepts.

6) What is meant by abstraction? 
     Abstraction defines the essential characteristics of an object that distinguish it from all other kinds of objects. Abstraction provides crisply-defined conceptual boundaries relative to the perspective of the viewer. Its the process of focusing on the essential characteristics of an object. Abstraction is one of the fundamental elements of the object model.

7) What is meant by Encapsulation? 
     Encapsulation is the process of compartmentalising the elements of an abtraction that defines the structure and behaviour. Encapsulation helps to separate the contractual interface of an abstraction and implementation.

8) What is meant by Inheritance
     Inheritance is a relationship among classes, wherein one class shares the structure or behaviour defined in another class. This is called Single Inheritance. If a class shares the structure or behaviour from multiple classes, then it is called Multiple Inheritance. Inheritance defines “is-a” hierarchy among classes in which one subclass inherits from one or more generalised superclasses.

9) What is meant by Polymorphism? 
     Polymorphism literally means taking more than one form. Polymorphism is a characteristic of being able to assign a different behavior or value in a subclass, to something that was declared in a parent class.

10) What is an Abstract Class? 
     Abstract class is a class that has no instances. An abstract class is written with the expectation that its concrete subclasses will add to its structure and behaviour, typically by implementing its abstract operations.

11) What is an Interface? 
     Interface is an outside view of a class or object which emphaizes its abstraction while hiding its structure and secrets of its behaviour.

12) What is a base class? 
     Base class is the most generalised class in a class structure. Most applications have such root classes. In Java, Object is the base class for all classes.

13) What is a subclass? 
     Subclass is a class that inherits from one or more classes

14) What is a superclass? 
     superclass is a class from which another class inherits.

15) What is a constructor? 
     Constructor is an operation that creates an object and/or initialises its state.

16) What is a destructor? 
     Destructor is an operation that frees the state of an object and/or destroys the object itself. In Java, there is no concept of destructors. Its taken care by the JVM.

17) What is meant by Binding? 
     Binding denotes association of a name with a class.

18) What is meant by static binding? 
     Static binding is a binding in which the class association is made during compile time. This is also called as Early binding.

19) What is meant by Dynamic binding? 
     Dynamic binding is a binding in which the class association is not made until the object is created at execution time. It is also called as Late binding.

20) Define Modularity? 
     Modularity is the property of a system that has been decomposed into a set of cohesive and loosely coupled modules.

21) What is meant by Persistence?
     Persistence is the property of an object by which its existence transcends space and time.

22) What is colloboration? 
     Colloboration is a process whereby several objects cooperate to provide some higher level behaviour.

23) In Java, How to make an object completely encapsulated? 
     All the instance variables should be declared as private and public getter and setter methods should be provided for accessing the instance variables.

24) How is polymorphism acheived in java? 
     Inheritance, Overloading and Overriding are used to acheive Polymorphism in java.

Android Packages


These are the Android APIs. See all API classes.
Contains resource classes used by applications included in the platform and defines application permissions for system features.
The classes in this package are used for development of accessibility service that provide alternative or augmented feedback to the user.
These classes provide functionality for the property animation system, which allows you to animate object properties of any type. intfloat, and hexadecimal color values are supported by default. You can animate any other type by telling the system how to calculate the values for that given type with a custom TypeEvaluator.
For more information, see the Animation guide.
Contains high-level classes encapsulating the overall Android application model.
Provides device administration features at the system level, allowing you to create security-aware applications that are useful in enterprise settings, in which IT professionals require rich control over employee devices.
For more information, see the Device Administration guide.
Contains the backup and restore functionality available to applications. If a user wipes the data on their device or upgrades to a new Android-powered device, all applications that have enabled backup can restore the user's previous data when the application is reinstalled.
For more information, see the Data Backup guide.
Contains the components necessary to create "app widgets", which users can embed in other applications (such as the home screen) to quickly access application data and services without launching a new activity.
For more information, see the App Widgets guide.
Provides classes that manage Bluetooth functionality, such as scanning for devices, connecting with devices, and managing data transfer between devices.
For more information, see the Bluetooth guide.
Contains classes for accessing and publishing data on a device.
Contains classes for accessing information about an application package, including information about its activities, permissions, services, signatures, and providers.
Contains classes for accessing application resources, such as raw asset files, colors, drawables, media or other other files in the package, plus important device configuration details (orientation, input types, etc.) that affect how the application may behave.
For more information, see the Application Resources guide.
Contains classes to explore data returned through a content provider.
Contains the SQLite database management classes that an application would use to manage its own private database.
Provides classes for managing DRM content and determining the capabilities of DRM plugins (agents).
Provides classes to create, recognize, load and save gestures.
Provides low level graphics tools such as canvases, color filters, points, and rectangles that let you handle drawing to the screen directly.
Provides classes to manage a variety of visual elements that are intended for display only, such as bitmaps and gradients.
Contains classes for drawing geometric shapes.
Provides support for hardware features, such as the camera and other sensors.
Provides support to communicate with USB hardware peripherals that are connected to Android-powered devices.
For more information, see the USB guide.
Base classes for writing input methods (such as software keyboards).
Contains classes that define Android location-based and related services.
For more information, see the Location and Maps guide.
Provides classes that manage various media interfaces in audio and video.
Provides classes that manage audio effects implemented in the media framework.
Provides classes that allow you to apply a variety of visual effects to images and videos.
Provides APIs that let you interact directly with connected cameras and other devices, using the PTP
(Picture Transfer Protocol) subset of the MTP (Media Transfer Protocol) specification.
Classes that help with network access, beyond the normal java.net.* APIs.
Provides APIs for RTP (Real-time Transport Protocol), allowing applications to manage on-demand
or interactive data streaming.
Provides access to Session Initiation Protocol (SIP) functionality, such as making and answering VOIP calls using SIP.
For more information, see the Session Initiation Protocol developer guide.
Provides classes to manage Wi-Fi functionality on the device.
Provides classes to create peer-to-peer (P2P) connections with Wi-Fi Direct.
Provides access to Near Field Communication (NFC) functionality, allowing applications to read NDEF message in NFC tags. A "tag" may actually be another device that appears as a tag.
For more information, see the Near Field Communication guide.
These classes provide access to a tag technology's features, which vary by the type of tag that is scanned.
Provides an OpenGL ES static interface and utilities.
Provides basic operating system services, message passing, and inter-process communication on the device.
Contains classes for the system storage service, which manages binary asset filesystems known as Opaque Binary Blobs (OBBs).
Provides classes that manage application preferences and implement the preferences UI.
Provides convenience classes to access the content providers supplied by Android.
The Renderscript rendering and computational APIs offer a low-level, high performance means of carrying out mathematical calculations and 3D graphics rendering.
For more information, see the Renderscript developer guide.
A framework that makes it easy to write efficient and robust SAX handlers.
Provides classes that allow you to create spell checkers in a manner similar to the input method framework (for IMEs).
Support classes to access some of the android.app package features introduced after API level 13 in a backwards compatible fashion.
Support classes to ease implementation of Dreams in a backwards compatible fashion.
Support android.accessibilityservice classes to assist with development of applications for android API level 4 or later.
Support android.app classes to assist with development of applications for android API level 4 or later.
Support android.content classes to assist with development of applications for android API level 4 or later.
Support android.content.pm classes to assist with development of applications for android API level 4 or later.
Support android.database classes to assist with development of applications for android API level 4 or later.
Support android.util classes to assist with development of applications for android API level 4 or later.
Support android.util classes to assist with development of applications for android API level 4 or later.
Support classes to access some of the android.view.accessibility package features introduced after API level 4 in a backwards compatible fashion.
Support android.widget classes to assist with development of applications for android API level 4 or later.
Provides APIs for monitoring the basic phone information, such as the network type and connection state, plus utilities for manipulating phone number strings.
Provides APIs for utilizing CDMA-specific telephony features.
Provides APIs for utilizing GSM-specific telephony features, such as text/data/PDU SMS messages.
A framework for writing Android test cases and suites.
For more information, see the Testing developer guide.
Utility classes providing stubs or mocks of various Android framework building blocks.
For more information, see the Testing guide.
Utility classes supporting the test runner classes.
Provides classes used to render or track text and text spans on the screen.
This package contains alternative classes for some text formatting classes defined in java.util and java.text.
Provides classes that monitor or modify keypad input.
Provides classes used to view or change the style of a span of text in a View object.
Utilities for converting identifiable text strings into clickable links and creating RFC 822-type message (SMTP) tokens.
Provides common utility methods such as date/time manipulation, base64 encoders and decoders, string and number conversion methods, and XML utilities.
Provides classes that expose basic user interface classes that handle screen layout and interaction with the user.
The classes in this package are used to represent screen content and changes to it as well as APIs for querying the global accessibility state of the system.
Provides classes that handle tweened animations.
Framework classes for interaction between views and input methods (such as soft keyboards).
Provides tools for browsing the web.
The widget package contains (mostly visual) UI elements to use on your Application screen.
Provides classes related to Dalvik bytecode.
Provides utility and system information classes specific to the Dalvik VM.
Provides the system's ReferenceQueue implementation as well as different forms of reference objects which impose special behavior on the garbage collector.
This package is for compatibility with legacy code only, and should not be used or expected to do anything useful.
This package provides the classes and the interfaces needed to build Access Control Lists.
This package provides all the classes and all the interfaces needed to generate, administer and verify X.509 certificates.
This package provides the interfaces needed to generate: (1) Keys for the RSA asymmetric encryption algorithm using the PKCS#1 standard; (2) Keys for the Digital Signature Algorithm (DSA) specified by FIPS-186; (3) Keys for a generic Elliptic Curve asymmetric encryption algorithm.
This package provides the classes and interfaces needed to specify keys and parameters for encryption and signing algorithms.
Provides a compatibility interface for accessing SQL-based databases.
Utility classes commonly useful in concurrent programming.
A small toolkit of classes that support lock-free thread-safe programming on single variables.
Interfaces and classes providing a framework for locking and waiting for conditions that is distinct from built-in synchronization and monitors.
This package provides the classes and interfaces for cryptographic applications implementing algorithms for encryption, decryption, or key agreement.
This package provides the interfaces needed to implement the Diffie-Hellman (DH) key agreement's algorithm as specified by PKCS#3.
This package provides the classes and interfaces needed to specify keys and parameter for encryption.
Provides a standard OpenGL interface.
This package provides factory classes to create sockets and server-sockets.
This package provides classes and interfaces needed to use the Secure Sockets Layer (SSL) protocol and the successor Transport Layer Security (TLS) protocol.
This package provides classes and interfaces needed to interact with the application in order to execute the authentication and authorization processes.
This package provides a pluggable and stackable authentication system based on ideas and concepts from the Unix-PAM module.
This package provides classes needed to store X.500 principals and their credentials.
This package is provided only for compatibility reasons.
Provides a utility class with useful XML constants.
XML/Java Type Mappings.
XML Namespace processing.
Provides classes allowing the processing of XML documents.
This package defines the generic APIs for processing transformation instructions, and performing a transformation from source to result.
This package implements DOM-specific transformation APIs.
This package implements SAX2-specific transformation APIs.
This package implements stream- and URI- specific transformation APIs.
This package provides an API for validation of XML documents.
This package provides an object-model neutral API for the evaluation of XPath expressions and access to the evaluation environment.
The junit test framework.
Utility classes supporting the junit test framework.
The core interfaces and classes of the HTTP components.
The API for client-side HTTP authentication against a server, commonly referred to as HttpAuth.
Parameters for configuring HttpAuth.
The API for client-side HTTP communication and entry point to the HttpClient module.
Request implementations for the various HTTP methods like GET and POST.
Parameters for configuring HttpClient.
Additional request and response interceptors.
Helpers and utility classes for HttpClient.
The client-side connection management and handling API at the heart of what is referred to as HttpConn.
Parameters for configuring HttpConn.
The client-side route representation and tracking API, part of HttpConn.
TLS/SSL specific parts of the HttpConn API.
The API for client-side state management via cookies, commonly referred to as HttpCookie.
Parameters for configuring HttpCookie.
Representations for HTTP message entities.
Default implementations for interfaces in org.apache.http.
The implementation of a thread-safe client connection manager.
Default implementations for interfaces in org.apache.http.entity.
Default implementations for interfaces in org.apache.http.io.
The transport layer abstraction of the HTTP components.
A selection of HTTP message implementations.
The parameterization framework for HTTP components.
HTTP protocol execution framework.
Mostly utility classes with static helper methods for various purposes.
Provides the official W3C Java bindings for the Document Object Model, level 2 core.
This package provides the core SAX APIs.
This package contains interfaces to SAX2 facilities that conformant SAX drivers won't necessarily support.
This package contains "helper" classes, including support for bootstrapping SAX-based applications.