Friday, December 19, 2014

Android Interview Questions and Answers


1. What is android?
A.Android is a stack of software for mobile devices which has Operating System, middleware and some key applications. The application executes within its own process and its own instance of Dalvik Virtual Machine.Many Virtual Machines run efficiently by a DVM device. DVM executes Java language byte code which later transforms into .dex format files.

2. What are the advantages of Android?
A. The following are the advantages of Android:
* The customer will be benefited from wide range of mobile applications to choose, since the monopoly of wireless carriers like AT&T and Orange will be broken by Google Android.
* Features like weather details, live RSS feeds, opening screen, icon on the opening screen can be customized
* Innovative products like the location-aware services, location of a nearby convenience store etc., are some ofthe additive facilities in Android. Components can be reused and replaced by the application framework.
* Optimized DVM for mobile devices
* SQLite enables to store the data in a structured manner.
* Supports GSM telephone and Bluetooth, WiFi, 3G and EDGE technologies
* The development is a combination of a device emulator, debugging tools, memory profiling and plug-in for Eclipse IDE.

3. Explain about the exceptions of Android?
A.The following are the exceptions that are supported by Android
* InflateException : When an error conditions are occurred, this exception is thrown
* Surface.OutOfResourceException: When a surface is not created or resized, this exception is thrown
* SurfaceHolder.BadSurfaceTypeException: This exception is thrown from the lockCanvas() method, when invoked on a Surface whose is SURFACE_TYPE_PUSH_BUFFERS
* WindowManager.BadTokenException: This exception is thrown at the time of trying to add view an invalid WindowManager.LayoutParamstoken.

4. Describe the APK format.
A.The APK file is compressed the AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.

5. What is .apk extension?A.The extension for an Android package file, which typically contains all of the files related to a single Android
application. The file itself is a compressed collection of an AndroidManifest.xml file, application code (.dex files), resource files, and other files. A project is compiled into a single .apk file.

6. What is .dex extension?
A.Android programs are compiled into .dex (Dalvik Executable) files, which are in turn zipped into a single .apk file on the device. .dex files can be created by automatically translating compiled applications written in the Java programming language.

7. Explain the Architecture of Android ?
A. Top -> Applications (Contacts, Browser, Phone, etc)
Below Applications -> Application Framework(Activity Manager, Window Manager, Content Providers, View
System, Package manager,
Telephony manager, Resource, Notification, Location managers)
Below Application Framework -> System Libraries(Like Sqlite, webkit, SSL, OpenGL, Media Framework etc) & Android Runtime( Core Libraries and DVM).
Atlast Last -> Linux Kernel (which composed of drivers like display, camera etc.)

10. What is an activity?
A. A single screen in an application, with supporting Java code.
An activity presents a visual user interface for one focused endeavor the user can undertake.
For example, an activity might present a list of menu items users can choose from or it might display
photographs along with their captions.

11. What is a service?
A.A service doesn’t have a visual user interface, but rather runs in the background for an indefinite period of time.
For example, a service might play background music as the user attends to other matters, or it might fetch data over the network or calculate something and provide the result to activities that need it.Each service extends the Service base class.

12. How to Remove Desktop icons and Widgets?
A. Press and Hold the icon or widget. The phone will vibrate and on the bottom of the phone you will see anoption to remove. While still holding the icon or widget drag it to the remove button. Once remove turns red drop the item and it is gone.

13. Describe a real time scenario where android can be used?
A .Imagine a situation that you are in a country where no one understands the language you speak and you can not read or write. However, you have mobile phone with you.

14. How to select more than one option from list in android xml file? ********
A. Give an example.
Specify android id, layout height and width as depicted in the following example.

15. What languages does Android support for application development?
A.Android applications are written using the Java programming language.

16. Describe Android Application Architecture?
A.Android Application Architecture has the following components:
 • Services – like N
 • Intent – To perform inter-communication network Operation between activities or services
 • Resource Externalization – such as strings and graphics
 • Notification signaling users – light, sound, icon, notification, dialog etc

17. What is the Android Open Source Project?
A. We use the phrase “Android Open Source Project” or “AOSP” to refer to the people, the processes, and the source code that make up Android.

18. Why did we open the Android source code?
A .Google started the Android project in response to our own experiences launching mobile apps. We wanted to make sure that there would always be an open platform available for carriers, OEMs, and developers to use to make their innovative ideas a reality. We also wanted to make sure that there was no central point of failure, so that no single industry player could restrict or control the innovations of any other. The single most important goal of the Android Open-Source Project (AOSP) is to make sure that the open-source Android software is implemented as widely and compatibly as possible, to everyone’s benefit.

19. What is the Guardian app for Android?
A.The Guardian app for Android delivers all the best content from guardian.co.uk to your phone or tablet. Read the latest news, sport, comment and reviews, watch video, listen to brodcasts and browse stunning picture galleries while on the move.

20. What features does it have?
A .- Navigate by section, topic or contributor
- Download your homepage and favourites for offline reading with the touch of a button, or schedule a daily download for a time that suits you
- Browse our award-winning audio and video content
- Save contributors, topics and sections to your favourites folder
- Add favourites to your homescreen with an expanded view or link
- Swipe through stunning full-screen picture galleries
- Share articles and galleries via the Android share function
- View content in portrait or landscape orientation

21. Will it work on my phone?
A.The app will work on all phones and tablets running Android version 1.6 and above.

22. How much does it cost?
A.The app is free and ad-supported.

23. How do I save the app to my SD card?
A. From the device's Settings menu, go to Applications > Manage applications > The Guardian. Under the data header, choose "Move to SD card".

24. How do I add sections to my favourites?
A. It is possible to add sections, topics and contributors to your favourites. You can add to favourites by tapping the star icon in the top right hand corner of the relevant screens, or on the right hand side of the headers in the all sections menu.

25. How do I remove sections from my favourites?
A. From the favourites menu, tap the red icons to the left hand side of the items. Alternatively, tap the star icon in the top right hand corner of the relevant screen so that it returns to its white state.

26. What is Mono for Android?
A. Mono for Android is a software development kit that allows developers to use the C# language to create mobile applications for Android-based devices.Mono for Android exposes two sets of APIs, the core .NET APIs that C# developers are familiar with as well as a C# binding to Android's native APIs exposed through theMono.Android.* namespace.You can use Mono for Android to develop applications that are distributed throughthe Android Application Stores or to deploy software to your personal hardware or the Android simulator.

27. What is included in Mono for Android?
A. Mono for Android consists of the core Mono runtime, the Mono for Android bindings to the native Android APIs, a Visual Studio 2010 plugin to develop Android applications and an SDK that contains the tools to build,debug and deploy your applicationsOur Visual Studio 2010 plugin allows developers to use Visual Studio 2010 to develop, debug and deploy their applications to an Android simulator, an Android device, or the Android Application Store.Our MonoDevelop IDE also ships an addin to support Mono for Android development.

28. What do I need to develop Mono for Android applications?
A. Mono for Android on Windows provides a plugin for Visual Studio 2010 Professional or better. We also support Mono for Android development using MonoDevelop on Windows for users that do not own a copy of Visual Studio 2010 Professional or better.Mono for Android on Mac developers can use MonoDevelop.On all platforms, Mono for Android requires the Android SDK (which requires Java JDK).

29. Will my users need to install Mono?
A. No, When you deploy your application to the app store the Mono mobile runtime is statically linked to your application. No additional dependancies are needed. From the users point of view, there is no difference between an application created in Java and an application created using Mono for Android, other than a slightly larger (~4.4MB) application size.

30. Where is the UI Designer?
A. Mono for Android does not bundle a UI designer to create the UI XML files We do not provide an
integrated UI designer in Mono for Android 1.0. No decisions past that have been made. We will be listening to user feedback to decide where to put resources for the future versions.

31. How is Mono for Android licensed?
A. Mono for Android is a commercial/proprietary offering that is built on top of the open source Mono project and is licensed on a per-developer basis.

32. What is the API profile exposed by Mono for Android?
A. Mono for Android uses the same API profile for the core libraries as MonoTouch.Specifically, MonoTouch and Mono for Android both support a Silverlight-based API, without Silverlight's UI libraries (e.g. no XML, no WindowsBase.dll, etc.), and free of the sandboxing limitations of Silverlight.

33. Are the Android releases available in a ROM?
A. No, Android is not yet available in a ROM format.Currently Android is installed by using a clean SD Card,and booted from there.It is booted by running a special application called 'Haret.exe' residing on your SD Cardwhich will terminate the Windows kernel and boot into Linux/Android.It can't easily be run from ROM because a) it's too experimental to risk putting in ROM and then killing a device and b) WinMo does some hardware initialization that isn't documented, but is needed before Android can run.

34. When will it be available in a ROM?
A. No time soon. Folks are working on it, but you'll need a lot of patience before it (if ever) arrives

35. How do I turn off, or reboot Android?
A. In earlier releases, you had to pull the battery or press the reset button, in newer releases, you can hold down the 'end call' button and see a menu.

36. Should we jump in to Android? What’s the guarantee that’s what I will see on a phone? Will service providers turn off things?
A. Keep in mind it hasn’t shipped yet, this is the most interesting time. Once it is open source, it could be locked down… they could create a derivative work.
We’re going to provide a piece of technology that tests the APIs. No time frame yet. The script will exercise the system. It’s a compatibility test suite, to make sure nothing got disabled or broken by accident, and also ensure that apps will work across OEMs.

37. What if my app uses location API, and service provider shuts that off, can they?
A. They can do that… it’s not a perfect world. Rather than having us dictate what carriers and OEMs support, we let developers develop killer apps that will require it.
We want to ensure all the application development that goes on for Android… we want to give OEMs an incentive to keep things open. It’s a positive, self fulfilling vision.

38.If I’m a game developer and I’m building piece of content and I want to sell it, how do I do that and realize revenue?
A. Content distribution — we’ve thought of that. It’d be great if there were a place where people could go to safely download and pay for content.

39. We use SMS interception for system signalling. Is there a mechanism for an app to respond and stopthe signaling chain? Is there security around that so that one vendor can’t hijack a message and respond to it?
A. There’s a mechanism where an application can register to receive a message with a certain signature and prevent others from getting it. We have a system of permissions apps are able to declare, enforce, and require to perform certain operations. Things like dial the phone, get to contacts, etc.. But these aren’t things that are baked in the core of the system. An arbitrary app could declare custom permissions. As far as restricting another app, the model we’ve been going by… the phone is not controlled by the application vendor, it’s controlled by the user. Whether or not the permissions are granted is up to the user that owns the phone. If you created a protocol that intercepts an SMS and another party wrote an app that intercepts the same SMS and the user wants to use that, the user could be free to stick that in.

40. Can the user set a priority?
A. Don’t know, post your question to the developer’s community board.

41. In a previous release, XMPP was turned into GTalk. Will a future version have XMPP?
A. Goal is to have XMPP support after 1.0. [Later they said both GTalk and XMPP were post 1.0 features. -Ed]

42. What’s so special about Android?
A. Unlike the proprietary iPhone operating system (now known as "iOS,"), which is under the complete control of Apple — and the same goes for Research in Motion’s BlackBerry OS or Microsoft’s Windows Phone platform — Google released Android as an open-source OS under the auspices of the Open Handset Alliance, leaving phone manufacturers (relatively) free to tweak Android as they see fit for a given handset. That’s one thing that’s special about Android. Another thing is that it just happens to be a really good OS, the first one in the post-iPhone wireless era to really give Apple a run for its money. Android may not be as sleek or polished as iOS (that’s my humble opinion, at least), but it’s fast and powerful, with an intuitive user interface that’s packed with options and flexibility. It’s also being constantly improved courtesy of the big brains at
Google, making the Android experience sleeker by the day.

43. Are Android phones called "Droids"?
A. Not necessarily. "Droid" is a brand name used by Verizon Wireless for its Android-based phones — the Droid X, the Droid Eris, the Droid Incredible and so on. The HTC Evo 4G on Sprint is not a "Droid," per se, but it’s still an Android smartphone.

44. Why would I (potentially) choose an Android phone over an iPhone?
A. Well, for a variety of reasons — although I should point out that I’m actually a fan of both operating systems. (Sorry to disappoint the smartphone flame warriors out there.)
One reason to go the Google way is that Android phones boast tight integration with Google services like Gmail, Google Calendar, Google Contacts and Google Voice — perfect for anyone who uses Google for all their e-mails, contacts and events. Indeed, one of the coolest things about Android phones is that the first time you fire one up, you enter your Google user name and password, and voila: All your Google messages, contactsand other info start syncing into your new handset automatically, no desktop syncing needed.
Android is also far more open when it comes to applications. Whereas Apple takes a "walled garden" approach to its App Store, Google won’t restrict you from installing apps that aren’t featured in its official Android Marketplace. iPhone users, on the other hand, must "jailbreak" their phones if they want to install apps that weren’t approved by Apple for inclusion in the App Store.
Last but not least, because Android is open to all manufacturers, a wide variety of Android phones are available to choose from — big and small, souped-up and pared-down, some with slide-out keyboards (good luckconvincing Steve Jobs to put a slide-out QWERTY on the iPhone) and some that are all-touchscreen, all the
time. Indeed, in the past few months, a new Android phone has debuted practically every week, while we only get a single new iPhone each year.

45. What are the downsides of Android?
A. Well, if you ask me, the Android OS isn’t quite as forgiving to wireless beginners as the iPhone is. Setting up your e-mail, contacts and calendar on Android is a breeze (if you’re all about Gmail, that is), but when it comes to, say, your music and videos, you’re on your own with Android, which lacks an official media syncing client for the desktop. With the iPhone, you do all your syncing on easy-to-use iTunes, which also lets you manage your e-mail accounts, contacts, apps and photos. Then again, you can only use iTunes for syncing the iPhone, while Android users have a variety of third-party options.
That’s just one example, but in general, Android gives you more options and choices about how you manage your phone and your mobile content — great for experienced and advanced users, but potentially intimating for new mobiles.
On the other hand, while beginners might appreciate the (usually) smooth, user-friendly experience that Apple has devised for the iPhone, advanced users may (and often do) get frustrated by Apple’s tight control over what they can and can't do on the iPhone. It’s a trade-off, plain and simple, and your choice of platform depends on what’s right for you.

46. What’s up with all these different versions of Android, like "Donut," "Cupcake" and "Froyo"?
A. Just as Apple does with iOS, Google continually updates Android with cool new features, leading to one "point" upgrade after another.
The most recent version of Android is 2.2, code-named "Froyo" (for frozen yogurt, yum), adds features such as native USB tethering (for sharing your Android phone’s data connection with a laptop via a USB cable), mobile hotspot functionality (which turns your phone into a portable Wi-Fi hotspot that works with nearby Wi-Fi devices) and — perhaps most important — support for Flash, meaning that Flash-powered videos and modules that (notoriously) don’t work on the iPhone will work on the Android Web browser.Before 2.2 Froyo, we had version 2.1, which added "live" animated wallpaper, new home screen icons and widgets (tiny apps for the home screen), speech-to-text functionality (for e-mail and text messages, for example), full-on multitouch (for pinch-to-zoom gestures), and an updated photo gallery that hooks into your Picasa Web albums. Android 1.6 "Donut" (someone at Google must have a sweet tooth) added various speed improvements, support for more screen resolutions, and faster camera and camcorder applications. The first
major update to Android was 1.5 "Cupcake," which (among other goodies) finally added a native video recorder.

47. So if the current version of Android is 2.2, why are people still complaining about Android phones stuck with version 2.1, or even 1.6?
A. Ah, well, here’s where we find one of the downsides of Google allowing so much diversity in terms of available Android handsets. Don’t get me wrong: Variety is a beautiful thing, especially when it comes to phones. But it also means that each new version of Android must be certified to work on a specific handset — a long and sometimes drawn-out process that can leave users of a particular Android smartphone waiting weeks or even months to get the latest and greatest features. Indeed, manufactures and carriers may decide that it’s not worth the effort to upgrade their older phones to the latest Android version, leaving users high and dry.
On the other hand, only a handful of iPhones exist, which makes it far easier for Apple to roll out a new version of iOS to everyone, all at once — or at least it used to be easy. Because of the hardware demands of iOS 4, we’ve already seen the original iPhone from 2007 get left behind, while users of the second-generation iPhone 3G have complained bitterly that the new iOS has slowed their handsets to a crawl. So it goes.

48. How many apps are available for Android?
A. About 70,000 or so, growing by the day — still just a fraction of the 225,000-plus apps in the Apple App Store, but the official Android Marketplace has quite the head of steam, not to mention plenty of goodwill from the developer community given that Google doesn’t give apps the star-chamber treatment.

49. So, how should I go about picking an Android phone?
A. No question about it: The breadth and variety of Android phones now on the market can be downright bewildering. The easiest way to narrow your choices is pretty obvious: What features and form-factors are you looking for? Do you want a phone with a real QWERTY keypad, or would you prefer one with only an onscreen keypad? Looking for a big screen (like the 4.3-inchers on the Evo 4G or the Droid X) or something that’s an easier fit in your pocket (like, say, the Droid Incredible)? Will you primarily be sending e-mail and text messages (in which case a smaller screen with a QWERTY would work), or are you interested in watching movies and other videos (big display)? Finally, who’s your carrier — or who would you like to be your carrier?
Note, it’s not rocket science. Once you’ve zeroed in on a phone, find out which version of Android it’s running on. Is it the latest and greatest? (For now, only the Motorola Droid 2 is shipping with Android 2.2, although a 2.2 update for the HTC Evo 4G has finally arrived.) If not, ask when — and whether — an update is on the way.

50. What are the hottest new Android phones out right now?
A. Well, earlier this summer we got the HTC Evo 4G, which supports Sprint’s budding, next-generation WiMax data network and boasts a 4.3-inch display — the same size as the screen on the Motorola Droid X, another eyepopper of a phone, except it’s on Verizon instead of Sprint. Samsung is in the midst of releasing a series of what it calls its Galaxy S-class Android phones: They’re thin and light, they all have high-contrast 4-inch "Super AMOLED" screens, and they’re available (or will be soon) on all four of the big U.S. carriers. If you’re looking for an Android phone with a slide-out QWERTY, consider the new Motorola Droid 2 on Verizon or the upcoming Samsung Epic 4G for Sprint.

51. How will you record a phone call in Android? How to get a handle on Audio Stream for a call in
Android?
A. Permissions.PROCESS_OUTGOING_CALLS: Allows an application to monitor, modify, or abort outgoing calls.

52. Why cannot you run standard Java bytecode on Android?
A. Android uses Dalvik Virtual Machine (DVM) which requires a special bytecode. We need to convert Java class files into Dalvik Executable files using an Android tool called "dx". In normal circumstances, developers will not be using this tool directly and build tools will care for the generation of DVM compatible files.

53. Can you deploy executable JARs on Android? Which packaging is supported by Android?
A. No. Android platform does not support JAR deployments. Applications are packed into Android Package (.apk) using Android Asset Packaging Tool (aapt) and then deployed on to Android platform. Google provides Android Development Tools for Eclipse that can be used to generate Android Package.

54. Android application can only be programmed in Java?
A. False. You can program Android apps in C/C++ using NDK .

55. What is an action?
A. The Intent Sender desires something or doing some task

56. What are Dalvik Executable files?
A. Dalvik Executable files have .dex extension and are zipped into a single .apk file on the device.

57. How does Android system track the applications?
A. Android system assigns each application a unique ID that is called Linux user ID. This ID is used to track each application.

58. When does Android start and end an application process?
A. Android starts an application process when application's component needs to be executed. It then closes the process when it's no longer needed (garbage collection).

59. How can two Android applications share same Linux user ID and share same VM?
A. The applications must sign with the same certificate in order to share same Linux user ID and share sameVM.

60. Can I use the GoToMeeting app for Android on my Android device?*****
A. Yes. If you’re running Android 2.2 or higher, you can install the GoToMeeting app from the Android Market to join meetings and webinars as an attendee. We recommend using devices with a 1Ghz processor or higher for optimal performance.

61. How can I download the GoToMeeting app?
A. You can download the GoToMeetng app from the Android Market by signing in to your Google account linked with your Android device and searching for the GoToMeeting app to install it. If you don’t see an Install button, you may not be running Android 2.2 or higher – the minimum system requirement needed to install the GoToMeeting app.You can also download the GoToMeeting app from the Amazon Appstore (only available in the U.S.), which lets you instantly download the GoToMeeting app to an Android device. If you have the GoToMeeting app pre-loaded onto your device, you’ll need to first upgrade to the latest version of GoToMeeting. To upgrade, select the GoToMeeting daisy icon and then select the Upgrade button to install the most recent version of the app.

62.If I have a Motorola Android-based device that doesn’t have the Android Market app, can I still download the GoToMeeting app?
A.Yes. Attendees using Motorola Android-based devices in China can now download the GoToMeeting app from SHOP4APPS™ – Motorola’s preinstalled Android application storefront. The GoToMeeting app is not yet localized in Chinese, but it is available in English, German, French, Spanish and Italian.

63.What made you jump into Android all of a sudden? Why not iOS or other mobile platforms?
A. Maxim Petrov: I've never intended to do any mobile startup, but I got an Android phone first (Nexus One), not iPhone, so I started to look into this platform first. The lack of Google's own music app was obvious. I think if it was iPhone, not Nexus One, I could go developing for iOS instead. Though, you know, there are a lot more really good apps that already exist for iOS (and existed a year ago), all niches are filled, Apple is pretty restrictive (I don't think PowerAMP iPhone version would have ever been accepted in the Appstore). You can jump into Android quickly - just download the SDK, install adb driver, and you can develop - for your phone, for your friends (first beta testers), it's much easier to start on Android, but I can only compare to what I've read about iOS development as I haven't developed anything for iPhone.

64.What were your initial impressions of Android development?
A.Maxim Petrov: Android developing (and actually, any software developing) is not about knowing the language - languages are just tools, so adding a tool to a toolbox is usually not a problem (I moved to Android/Java/C dev right from Ruby - and these are completely different languages). Given experience with any other languages, you can move to Android pretty quickly, at least start prototyping something, though, you need to fight the initial quirks (like SDK installation, lack of good documentation, android SDK/Eclipse and framework bugs, and the Android core devs' "you can't do that, please don't do that").Android development
infrastructure is very immature, while Android end user can never notice the immaturity of the platform (as actually, it's not so immature on end user side), the development side of things is really lacking in many areas. For example, documentation is lacking, often conflicts with real state of things and it's just not enough. Though, this is balanced by the fact that Android is open source - you can just go check the source, and the source is the best documentation, but you need to get used (I am) to this approach. For example, Honeycomb sources are not published yet, and this immediately raised questions, like how do they activate that menu button in bottom status bar.

65. Does Android support Adobe Flash in the browser?
A.Flash support varies by device with Android 2.1. The Samsung Acclaim does not have Flash support upon launch, but the HTC Desire will support Flash Lite 4.0 running Android 2.1. Flash 10.1 support is coming toAndroid-powered phones with Android 2.2.

66.Does Android support push email or is it pull?
A. Android 2.1 supports push e-mail for Exchange mail and Gmail.

67. Will these phones have world phone capabilities, with the ability to make calls, receive data in othercountries? Or will they be able to use Google Voice to make calls?
A.Our Android-powered phones have Wi-Fi which can be used abroad for data, including Google Voice formaking international calls. International Roaming for voice is available in several countries.

68. Will the App run on my Android phone?
A. Yes, our App is fully compatible with any Android phone running Android software v2.1 or later.

69. How do I install your App?
A. You can install our App from the Android Market by following the below steps:
Open the Android Market application in the Applications menu.
Hit the search icon and type in E.ON
To install it, hit the ‘Free’ button on the left hand side
In the next screen, it will give you more details about the application including the different functionalities it will need to access. Just click on OK to finish installing the application.

70. How do I find and download updates to the E.ON Android application?
A. Any updates to our App will appear on your notification menu at the top of your screen. Just tap on the E.ON App icon and you'll be taken into the Android Market and be presented with the E.ON App download page.

71. What do I do if I have problems downloading your App?
A. If you receive a "Download unsuccessful" message when trying to download our App you can try the following steps:
Restart your phone and then try downloading the app again.
Make sure that you’re connected to your network – if you’re not you’ll need to contact your mobile service provider Wait up to 10 minutes and try to download our App again.
If you get stuck at "Starting download" then:
Make sure that you’re connected to your network – if you’re not you’ll need to contact your mobile service provider If your request to download our App doesn’t start at all then try the below:
Check your connectivity as stated aboveMake sure that your phone has enough available space to install our App. If you need to, try uninstalling some apps that you don’t use anymore or moving them to your SD card. Request the download again using Android Market from your device.

72. What is an Intent?
A class (Intent) which describes what a caller desires to do. The caller will send this intent to Android's intent resolver, which finds the most suitable activity for the intent. E.g. opening a PDF document is an intent, and theAdobe Reader apps will be the perfect activity for that intent (class).

73. What is a Sticky Intent?
A. Sticky Intent is also a type of Intent which allows a communication between a function and a service sendStickyBroadcast() performs a sendBroadcast(Intent) known as sticky, i.e. the Intent you are sending stays around after the broadcast is complete, so that others can quickly retrieve that data through the return value of registerReceiver(BroadcastReceiver, IntentFilter). In all other ways, this behaves the same as sendBroadcast(Intent). One example of a sticky broadcast sent via the operating system is ACTION_BATTERY_CHANGED. When you call registerReceiver() for that action -- even with a null BroadcastReceiver -- you get the Intent that was last broadcast for that action. Hence, you can use this to find the state of the battery without necessarily registering for all future state changes in the battery.

74. How the nine-patch Image different from a regular bitmap? Alternatively, what is the difference between nine-patch Image vs regular Bitmap Image?
A.It is one of a resizable bitmap resource which is being used as backgrounds or other images on the device. The NinePatch class allows drawing a bitmap in nine sections. The four corners are unscaled; the middle of the image is scaled in both axes, the four edges are scaled into one axis.

75. What is a resource?
A. user defined JSON, XML, bitmap, or other file, injected into the application build process, which can later be loaded from code.

76.How will you record a phone call in Android? or How to handle an Audio Stream for a call in Android?
Permission.PROCESS_OUTGOING_CALLS: Will Allow an application to monitor, modify, or abort outgoing calls. So using that permission we can monitor the Phone calls.

77.Does Android support the Bluetooth serial port profile?
 Yes.

78. Can an application be started on powerup?
Yes.

79. How to Translate in Android?
The Google translator translates the data of one language into another language by using XMPP to transmit data. You can type the message in English and select the language which is understood by the citizens of the country in order to reach the message to the citizens.

80. Describe Briefly the Android Application Architecture
Android Application Architecture has the following components:
Services like Network Operation Intent - To perform inter-communication between activities or servicesResource Externalization - such as strings and graphics
Notification signaling users - light, sound, icon, notification, dialog etc.
Content Providers - They share data between applications.

81. What is needed to make a multiple choice list with a custom view for each row?
A. Multiple choice list can be viewed by making the CheckBox android:id value be “@android:id /text1". That is the ID used by Android for the CheckedTextView in simple_list_item_multiple_choice.

82. What dialog boxes are supported in Android ?Android supports 4 dialog boxes:
? AlertDialog: An alert dialog box supports 0 to 3 buttons and a list of selectable elements, including
check boxes and radio buttons. Among the other dialog boxes, the most suggested dialog box is the alert dialog box.? ProgressDialog: This dialog box displays a progress wheel or a progress bar. It is an extension of AlertDialog and supports adding buttons.
? DatePickerDialog: This dialog box is used for selecting a date by the user.
? TimePickerDialog: This dialog box is used for selecting time by the user.

83.Introduction Android:
Android is an operating system for mobile devices that includes middleware and key applications, and uses a modified version of the Linux kernel. It was initially developed by Android Inc..It allows developers to write managed code in the Java language, controlling the device via Google-developed Java libraries…..
The Android SDK includes a comprehensive set of development tools . These include a debugger, libraries, a handset emulator (based on QEMU), documentation, sample code, and tutorials. Currently supported development platforms include x86-architecture computers running Linux (any modern desktop Linux distribution), Mac OS X 10.4.8 or later, Windows XP or Vista.
Android does not use established Java standards, i.e. Java SE and ME. This prevents compatibility among Java applications written for those platforms and those for the Android platform. Android only reuses the Java language syntax, but does not provide the full-class libraries and APIs bundled with Java SE or ME.

84.Features of Android:
Application framework enabling reuse and replacement of components Dalvik virtual machine optimized for mobile devices Integrated browser based on the open source WebKit engine
Optimized graphics powered by a custom 2D graphics library; 3D graphics based on the OpenGL ES 1.0 specification (hardware acceleration optional)
SQLite for structured data storage Media support for common audio, video, and still image formats (MPEG4, H.264, MP3, AAC, AMR, JPG,
PNG, GIF) GSM Telephony (hardware dependent)
Bluetooth, EDGE, 3G, and WiFi (hardware dependent)
Camera, GPS, compass, and accelerometer (hardware dependent)
Rich development environment including a device emulator, tools for debugging, memory and performance profiling, and a plugin for the Eclipse IDE.

85.What is an Application ?
A. Collection of one or more activities, services, listeners, and intent receivers. An application has a single manifest, and is compiled into a single .apk file on the device.

86.What is a Content Provider ?
A. A class built on ContentProvider that handles content query strings of a specific format to return data in a specific format. See Reading and writing data to a content provider for information on using content providers.

87. What is a Dalvik ?
A. The name of Android’s virtual machine. The Dalvik VM is an interpreter-only virtual machine that executes files in the Dalvik Executable (.dex) format, a format that is optimized for efficient storage and memorymappable execution. The virtual machine is register-based, and it can run classes compiled by a Java language compiler that have been transformed into its native format using the included “dx” tool. The VM runs on top of Posix-compliant operating systems, which it relies on for underlying functionality (such as threading and low level memory management). The Dalvik core class library is intended to provide a familiar development base for those used to programming with Java Standard Edition, but it is geared specifically to the needs of a small mobile device.

88.What is an DDMS ?
A. Dalvik Debug Monitor Service, a GUI debugging application shipped with the SDK. It provides screen capture, log dump, and process examination capabilities.

89.What is Drawable?
A. A compiled visual resource that can be used as a background, title, or other part of the screen. It is compiled into an android.graphics.drawable subclass.

90.What are fragments in Android Activity ?
A. Fragment represents a behavior or a portion of user interface in an Activity. And it is a self-contained component with its own UI and lifecycle.

91. What is Service?
A. Service doesn't have a visual user interface , but rather runs in the background for an indefinite period of time. For Example, a service might play background for music as the user attends to other matters.

92. What is BroadReceivers?
A. BroadcastReceiver is a component that does nothing but receive and react to broadcast announcements. For example, the battery is low or that the user changed a language preference.

93. Android latest Version?
A. Android 4.0.3

94.How many ways data stored in Android?
 1.SharedPreferences
 2.Internal Storage
 3.External Storage
 4.SQLite Database
 5.Network connection

95. Types of Android applications?
 1.Foreground
 2.Background
 3.Intermittent
 4.Widget

96. Android Development Tools?
A. The Android SDK and Virtual Device Manager Used to create and manage Android Virtual Devices (AVD) and SDK packages.
The Android Emulator An implementation of the Android virtual machine designed to run within a virtual device on your development computer. Use the emulator to test and debug your Android applications. Dalvik Debug Monitoring Service(DDMS) Use the DDMS perspective to monitor and control the Dalvik virtual machines on which your debugging your application.
Android Asset Packaging Tool(AAPT) Constructs the destributable Android packages files (.apk).
Android Debug Bridge(ADB) A client-server application that provedes a link to a running emulator.It lets you copy files, install compiled application packages(.apk),and run shell commands.

97.What is View in Android?
A. Views are the base class for all visual interface elements(commonly known as controls or widgets).All UI controls,including the layout classes,are derived for View.

98. What View Group in Android?
A. View Groups are extensions of the View class that can contain multiple child View.Extend the ViewGroupclass to create compound controls made up of interconnected child Views.

99.Implicent Intents and Late Runtime Binding?
A. An implicit Intent is mechanism that lets anonymous application components service action request. That means you can ask the system to launch an Activity that can perform a given action without knowing which application ,or Activity , will do so.

100. What are Native Android Actions?
A. Native Android applications also use Intents to launch Activities and sub Activities
ACTION-ANSWER Opens an Activity that handles immediately initiates a call using the number supplied in the Intent URI. Genereally it's considered better from to use ACTION_DIAL if possible.
ACTION_DELETE Starts an Activity hat lets you delete the data specified at that Intent's data URI.
ACTION_DIAL Brings up a dialer application with the number to dial pre-populated from the Intent URI. By default this is handled by the native Android phone dialer.
ACTION_EDIT Requests an Activity that can edit that data at the specified Intent URI.
ACTION_INSERT
ACTION_PICK
ACTION_SEARCH
ACTION_SENDTO
ACTION_SEND
ACTION_VIEW
ACTION_WEB_SEARCH

101.What is Pending Intent?
A.The PendingIntent class provides a mechanism for creating Intents that can be fired by another application at a later time. A pending Intent is commonly used to package an Intent will be fired in response to a future event,such as a widget View being clicked or a Notification being selected from the notification panel.

102. What is Adapter?
A. Adapter are bridging classes that bind data to Views(such as List Views) used in the user interface.
The adapter is responsible for creating for creating the child Views used to represent each item within
the parent View, and providing access to the underlying data.

ADO.Net Interview Questions.


1. What is the full form of ADO?

The full form of ADO is ActiveX Data Object.

2. Explain ADO.NET in brief.

ADO.NET is a very important feature of .NET Framework, which is used to work with data that is stored in structured data sources, such as databases and XML files. The

following are some of the important features of ADO.NET:
Contains a number of classes that provide you with various methods and attributes to manage the communication between your application and data source.
Enables you to access different data sources, such as Microsoft SQL Server, and XML, as per your requirements.
Provides a rich set of features, such as connection and commands that can be used to develop robust and highly efficient data services in .NET applications.
Provides various data providers that are specific to databases produced by various vendors. For example, ADO.NET has a separate provider to access data from Oracle

databases; whereas, another provider is used to access data from SQL databases.

3. What are major difference between classic ADO and ADO.NET?

Following are some major differences between both
In ADO we have recordset and in ADO.NET we have dataset.
In recordset we can only have one table. If we want to accommodate more than one tables. We need to do inner join and fill the recordset. Dataset can have multiple

tables.
All data persist in XML as compared to classic ADO where data persisted in Binary format also.

4. What are the two fundamental objects in ADO.NET?

DataReader and DataSet are the two fundamental objects in ADO.NET.

5. What are the benefits of using of ADO.NET in .NET 4.0.

The following are the benefits of using ADO.NET in .NET 4.0 are as follows:
Language-Integrated Query (LINQ) - Adds native data-querying capabilities to .NET languages by using a syntax similar to that of SQL. This means that LINQ simplifies

querying by eliminating the need to use a separate query language. LINQ is an innovative technology that was introduced in .NET Framework 3.5.
LINQ to DataSet - Allows you to implement LINQ queries for disconnected data stored in a dataset. LINQ to DataSet enables you to query data that is cached in a DataSet

object. DataSet objects allow you to use a copy of the data stored in the tables of a database, without actually getting connected to the database.
LINQ to SQL - Allows you to create queries for data stored in SQL server database in your .NET application. You can use the LINQ to SQL technology to translate a query

into a SQL query and then use it to retrieve or manipulate data contained in tables of an SQL Server database. LINQ to SQL supports all the key functions that you like

to perform while working with SQL, that is, you can insert, update, and delete information from a table.
SqlClient Support for SQL Server 2008 - Specifies that with the starting of .NET Framework version 3.5 Service Pack (SP) 1, .NET Framework Data Provider for SQL Server

(System.Data.SqlClient namespace) includes all the new features that make it fully compatible with SQL Server 2008 Database Engine.
ADO.NET Data Platform - Specifies that with the release of .NET Framework 3.5 Service Pack (SP) 1, an Entity Framework 3.5 was introduced that provides a set of Entity

Data Model (EDM) functions. These functions are supported by all the data providers; thereby, reducing the amount of coding and maintenance in your application. In

.NET Framework 4.0, many new functions, such as string, aggregate, mathematical, and date/time functions have been added.

6. Which namespaces are required to enable the use of databases in ASP.NET pages?

The following namespaces are required to enable the use of databases in ASP.NET pages:
The System.Data namespace.
The System.Data.OleDb namespace (to use any data provider, such as Access, Oracle, or SQL)
The System.Data.SQLClient namespace (specifically to use SQL as the data provider).

7. Explain the DataAdapter.Update() and DataSet.AcceptChanges() methods.

The DataAdapter.Update() method calls any of the DML statements, such as the UPDATE, INSERT, or DELETE statements, as the case may be to update, insert, or delete a

row in a DataSet. The DataSet.Acceptchanges() method reflects all the changes made to the row since the last time the AcceptChanges() method was called.

8. What is the meaning of object pooling?

Object pooling is a concept of storing a pool (group) of objects in memory that can be reused later as needed. Whenever, a new object is required to create, an object

from the pool can be allocated for this request; thereby, minimizing the object creation. A pool can also refer to a group of connections and threads. Pooling,

therefore, helps in minimizing the use of system resources, improves system scalability, and performance.

9. Which properties are used to bind a DataGridView control?

The DataSource property and the DataMember property are used to bind a DataGridView control.

10. What property must be set and what method must be called in your code to bind the data from some data source to the Repeater control?

You must set the DataSource property and call the DataBind() method.

11. Mention the namespace that is used to include .NET Data Provider for SQL server in .NET code.

The System.Data.SqlClient namespace.

12. What is the difference between OLEDB Provider and SqlClient?

With respect to usage, there is no difference between OLEDB Provider and SqlClient. The difference lies in their performance. SqlClient is explicitly used to connect

your application to SQL server directly, OLEDB Provider is generic for various databases, such as Oracle and Access including SQL Server.

Therefore, there will be an overhead which leads to performance degradation.

13. Name the two properties of the GridView control that have to be specified to turn on sorting and paging.

The properties of the GridView control that need to be specified to turn on sorting and paging are as follows:
The AllowSorting property of the Gridview control indicates whether sorting is enabled or not. You should set the AllowSorting property to True to enable sorting.
The AllowPaging property of the Gridview control indicates whether paging is enabled or not. You should set the AllowPaging property to True to enable paging.

14. Mention different types of data providers available in .NET Framework.

.NET Framework Data Provider for SQL Server - Provides access to Microsoft SQL Server 7.0 or later version. It uses the System.Data.SqlClient namespace.
.NET Framework Data Provider for OLE DB - Provides access to databases exposed by using OLE DB. It uses the System.Data.OleDb namespace.
.NET Framework Data Provider for ODBC - Provides access to databases exposed by using ODBC. It uses the System.Data.Odbc namespace.
.NET Framework Data Provider for Oracle - Provides access to Oracle database 8.1.7 or later versions. It uses the System.Data.OracleClient namespace.

15. Which architecture does Datasets follow?

Datasets follow the disconnected data architecture.

16. What is the role of the DataSet object in ADO.NET?

One of the major component of ADO.NET is the DataSet object, which always remains disconnected from the database and reduces the load on the database.

17. What is a DataReader object?

The DataReader object helps in retrieving the data from a database in a forward-only, read-only mode. The base class for all the DataReader objects is the DbDataReader

class.

The DataReader object is returned as a result of calling the ExecuteReader() method of the Command object. The DataReader object enables faster retrieval of data from

databases and enhances the performance of .NET applications by providing rapid data access speed. However, it is less preferred as compared to the DataAdapter object

because the DataReader object needs an Open connection till it completes reading all the rows of the specified table.

An Open connection to read data from large tables consumes most of the system resources. When multiple client applications simultaneously access a database by using

the DataReader object, the performance of data retrieval and other related processes is substantially reduced. In such a case, the database might refuse connections to

other .NET applications until other clients free the resources.

18. How can you identify whether or not any changes are made to the DataSet object since it was last loaded?

The DataSet object provides the following two methods to track down the changes:
The GetChanges() method - Returns the DataSet object, which is changed since it was loaded or since the AcceptChanges() method was executed.
The HasChanges() method - Indicates if any changes occurred since the DataSet object was loaded or after a call to the AcceptChanges() method was made.

If you want to revert all changes since the DataSet object was loaded, use the RejectChanges() method.

19. Which property is used to check whether a DataReader is closed or opened?

The IsClosed property is used to check whether a DataReader is closed or opened. This property returns a true value if a Data Reader is closed, otherwise a false value

is returned.

20. Name the method that needs to be invoked on the DataAdapter control to fill the generated DataSet with data?

The Fill() method is used to fill the dataset with data.

21. What is the use of the Connection object?

The Connection object is used to connect your application to a specific data source by providing the required authentication information in connection string. The

connection object is used according to the type of the data source. For example, the OleDbConnection object is used with an OLE-DB provider and the SqlConnection

object is used with an MS SQL Server.

22. What is the use of the CommandBuilder class?

The CommandBuilder class is used to automatically update a database according to the changes made in a DataSet.

This class automatically registers itself as an event listener to the RowUpdating event. Whenever data inside a row changes, the object of the CommandBuilder class

automatically generates an SQL statement and uses the SelectCommand property to commit the changes made in DataSet.

OLEDB provider in .NET Framework has the OleDbCommandBuiider class; whereas, the SQL provider has the SqlCommandBuilder class.

23. Explain the architecture of ADO.NET in brief.

AD0.NET consists of two fundamental components:
The DataSet, which is disconnected from the data source and does not need to know where the data that it holds is retrieved from.
The .net data provider, which allows you to connect your application to the data source and execute the SQL commands against it.

The data provider contains the Connection, Command, DataReader, and DataAdapter objects. The Connection object provides connectivity to the database. The Command

object provides access to database commands to retrieve and manipulate data in a database. The DataReader object retrieves data from the database in the readonly and

forward-only mode. The DataAdapter object uses Command objects to execute SQL commands. The DataAdapter object loads the DataSet object with data and also updates

changes that you have made to the data in the DataSet object back to the database.

24. Describe the disconnected architecture of ADO.NET's data access model.

ADO.NET maintains a disconnected database access model, which means, the application never remains connected constantly to the data source. Any changes and operations

done on the data are saved in a local copy (dataset) that acts as a data source. Whenever, the connection to the server is re-established, these changes are sent back

to the server, in which these changes are saved in the actual database or data source.

25. What are the usages of the Command object in ADO.NET?

The following are the usages of the Command object in AD0.NET:

The Command object in AD0.NET executes a command against the database and retrieves a DataReader or DataSet object.

It also executes the INSERT, UPDATE, or DELETE command against the database.
All the command objects are derived from the DbCommand class.
The command object is represented by two classes: SqlCommand and OleDbCommand.
The Command object provides three methods to execute commands on the database:
The ExecuteNonQuery() method executes a Transact-SQL statement against the connection and returns the number of rows affected.
The ExecuteScalar() method returns a single value from a database query.
The ExecuteReader() method returns a result set by using the DataReader object.

26. What are the pre-requisites for connection pooling?

The prerequisites for connection pooling are as follows:
There must be multiple processes to share the same connection describing the same parameters and security settings.
The connection string must be identical.

27. What is connection pooling?

Connection pooling refers to the task of grouping database connections in cache to make them reusable because opening new connections every time to a database is a

time-consuming process. Therefore, connection pooling enables you to reuse already existing and active database connections, whenever required, and increasing the

performance of your application.

You can enable or disable connection pooling in your application by setting the pooling property to either true or false in connection string. By default, it is

enabled in an application.

28. What are the various methods provided by the DataSet object to generate XML?

The various methods provided by the DataSet object to generate XML are:
ReadXml() - Reads XML document into a DataSet object.
GetXml() - Returns a string containing an XML document.
WriteXml() - Writes an XML data to disk.
29. Out of Windows authentication and SQL Server authentication, which authentication technique is considered as a trusted authentication method?

The Windows authentication technique is considered as a trusted authentication method because the username and password are checked with the Windows credentials stored

in the Active Directory.

The SQL Server Authentication technique is not trusted as all the values are verified by SQL Server only.

30. How would you connect to a database by using .NET?

The connection class is used to connect a .NET application with a database.

31. Which adapter should you use, if you want to get the data from an Access database?

OleDbDataAdapter is used to get the data from an Access database.

32. Which object is used to add a relationship between two DataTable objects?

The DataRelation object is used to add relationship between two DataTable objects.

33. What are different types of authentication techniques that are used in connection strings to connect .NET applications with Microsoft SQL Server?

.NET applications can use two different techniques to authenticate and connect with SQL Server. These techniques are as follows:
The Windows Authentication option
The SQL Server Authentication option

34. Explain the new features in ADO.NET Entity Framework 4.0.

ADO.NET Entity Framework 4.0 is introduced in .NET Framework 4.0 and includes the following new features:
Persistence Ignorance - Facilitates you to define your own Plain Old CLR Objects (POCO) which are independent of any specific persistence technology.
Deferred or Lazy Loading - Specifies that related entities can be loaded automatically whenever required. You can enable lazy loading in your application by setting

the DeferredLoadingEnabled property to true.
Self-Tracking Entities - Refers to the entities that are able to track their own changes. These changes can be passed across process boundaries and saved to the

database.
Model-First Development - Allows you to create your own EDM and then generate relational model (database) from that EDM with matching tables and relations.
Built-in Functions - Enables you to use built-in SQL Server functions directly in your queries.
Model-Defined Functions - Enables you to use the functions that are defined in conceptual schema definition language (CSDL).

35. What is the difference between the Clone() and Copy() methods of the DataSet class?

The Clone() method copies only the structure of a DataSet. The copied structure includes all the relation, constraint, and DataTable schemas used by the DataSet. The

Clone() method does not copy the data, which is stored in the DataSet.

The Copy() method copies the structure as well as the data stored in the DataSet.

36. What is the use of DataView?

User-defined view of a table is contained in a DataView. A complete table or a small section of table depending on some criteria can be presented by an object of the

DataView class. You can use this class to sort and find data within DataTable.

The DataView class has the following methods:
Find() - Finds a row in a DataView by using sort key value.
FindRows() - Uses the sort key value to match it with the columns of DataRowView objects. It returns an array of all the corresponding objects of DataRowView whose

columns match with the sort key value.
AddNew() - Adds a new row to the DataView object.
Delete() - Deletes the specified row from the DataView object according to the specified index.

37. What are the parameters that control most of connection pooling behaviors?

The parameters that control most of connection pooling behaviors are as follows:
Connect Timeout
Max Pool Size
Min Pool Size
Pooling

38. How can you add or remove rows from the DataTable object of DataSet?

The DataRowCollection class defines the collection of rows for the DataTable object in a DataSet. The DataTable class provides the NewRow() method to add a new DataRow

to DataTable. The NewRow method creates a new row, which implements the same schema as applied to the DataTable. The following are the methods provided by the

DataRowCollection object:
Add() - Adds a new row to DataRowCollection.
Remove()- Removes a DataRow object from DataRowCollection.
RemoveAt() - Removes a row whose location is specified by an index number.

39. Explain in brief DataAdapter class in ADO.NET.

The DataAdapter class retrieves data from the database, stores data in a dataset, and reflects the changes made in the dataset to the database. The DataAdapter class

acts as an intermediary for all the communication between the database and the DataSet object. The DataAdapter Class is used to fill a DataTable or DataSet Object with

data from the database using the Fill() method. The DataAdapter class applies the changes made in dataset to the database by calling the Update() method.

The DataAdapter class provides four properties that represent the database command:

SelectCommand, InsertCommand, DeleteCommand, and UpdateCommand.

.NET Framework Interview Questions and Answers.


1. What are the main components of .NET Framework?

.NET Framework provides enormous advantages to software developers in comparison to the advantages provided by other platforms. Microsoft has united various modern as

well as existing technologies of software development in .NET Framework. These technologies are used by developers to develop highly efficient applications for modern

as well as future business needs. The following are the key components of .NET Framework:

.NET Framework Class Library
Common Language Runtime
Dynamic Language Runtimes (DLR)
Application Domains
Runtime Host
Common Type System
Metadata and Self-Describing Components
Cross-Language Interoperability
.NET Framework Security
Profiling
Side-by-Side Execution.

2. What is .NET Framework?

.NET Framework is a complete environment that allows developers to develop, run, and deploy the following applications:

Console applications
Windows Forms applications
Windows Presentation Foundation (WPF) applications
Web applications (ASP.NET applications)
Web services
Windows services
Service-oriented applications using Windows Communication Foundation (WCF)
Workflow-enabled applications using Windows Workflow Foundation (WF)

.NET Framework also enables a developer to create sharable components to be used in distributed computing architecture. NET Framework supports the object-oriented

programming model for multiple languages, such as Visual Basic, Visual C#, and Visual C++. .NET Framework supports multiple programming languages in a manner that

allows language interoperability. This implies that each language can use the code written in some other language.

3. List the new features added in .NET Framework 4.0.

The following are the new features of .NET Framework 4.0:

Improved Application Compatibility and Deployment Support
Dynamic Language Runtime
Managed Extensibility Framework
Parallel Programming framework
Improved Security Model
Networking Improvements
Improved Core ASP.NET Services
Improvements in WPF 4
Improved Entity Framework (EF)
Integration between WCF and WF

4. What is an IL?

Intermediate Language is also known as MSIL (Microsoft Intermediate Language) or CIL (Common Intermediate Language). All .NET source code is compiled to IL. IL is then

converted to machine code at the point where the software is installed, or at run-time by a Just-In-Time (JIT) compiler.

5. What is Manifest?

Assembly metadata is stored in Manifest. Manifest contains all the metadata needed to do the following things
Version of assembly.
Security identity.
Scope of the assembly.
Resolve references to resources and classes.

The assembly manifest can be stored in a PE file either (an .exe or) .dll with Microsoft
intermediate language (MSIL code with Microsoft intermediate language (MSIL) code or in a
stand-alone PE file, that contains only assembly manifest information.

6. What are code contracts?

Code contracts help you to express the code assumptions and statements stating the behavior of your code in a language-neutral way. The contracts are included in the

form of pre-conditions, post-conditions and object-invariants. The contracts help you to improve-testing by enabling run-time checking, static contract verification,

and documentation generation.

The System.Diagnostics.Contracts namespace contains static classes that are used to express contracts in your code.

7. Name the classes that are introduced in the System.Numerics namespace.

The following two new classes are introduced in the System.Numerics namespace:
BigInteger - Refers to a non-primitive integral type, which is used to hold a value of any size. It has no lower and upper limit, making it possible for you to perform

arithmetic calculations with very large numbers, even with the numbers which cannot hold by double or long.
Complex - Represents complex numbers and enables different arithmetic operations with complex numbers. A number represented in the form a + bi, where a is the real

part, and b is the imaginary part, is a complex number.

8. What is managed extensibility framework?

Managed extensibility framework (MEF) is a new library that is introduced as a part of .NET 4.0 and Silverlight 4. It helps in extending your application by providing

greater reuse of applications and components. MEF provides a way for host application to consume external extensions without any configuration requirement.

9. Explain memory-mapped files.

Memory-mapped files (MMFs) allow you map the content of a file to the logical address of an application. These files enable the multiple processes running on the same

machine to share data with each Other. The MemoryMappedFile.CreateFromFile() method is used to obtain a MemoryMappedFile object that represents a persisted memory-

mapped file from a file on disk.

These files are included in the System.IO.MemoryMappedFiles namespace. This namespace contains four classes and three enumerations to help you access and secure your

file mappings.

10. What is Common Type System (CTS)?

CTS is the component of CLR through which .NET Framework provides support for multiple languages because it contains a type system that is common across all the

languages. Two CTS-compliant languages do not require type conversion when calling the code written in one language from within the code written in another language.

CTS provide a base set of data types for all the languages supported by.NET Framework. This means that the size of integer and long variables is same across all .NET-

compliant programming languages. However, each language uses aliases for the base data types provided by CTS. For example, CTS uses the data type system. int32 to

represent a 4 byte integer value; however, Visual Basic uses the alias integer for the same; whereas, C# uses the alias int. This is done for the sake of clarity and

simplicity.

11. Give a brief introduction on side-by-side execution. Can two applications, one using private assembly and the other using the shared assembly be stated as side-

by-side executables?

Side-by-side execution enables you to run multiple versions of an application or component and CLR on the same computer at the same time. As versioning is applicable

only to shared assemblies and not to private assemblies, two applications, one using a private assembly and other using a shared assembly, cannot be stated as side-

by-side executables.

12. Which method do you use to enforce garbage collection in .NET?

The System.GC.Collect() method.

13. State the differences between the Dispose() and Finalize().

CLR uses the Dispose and Finalize methods to perform garbage collection of run-time objects of .NET applications.

The Finalize method is called automatically by the runtime. CLR has a garbage collector (GC), which periodically checks for objects in heap that are no longer

referenced by any object or program. It calls the Finalize method to free the memory used by such objects. The Dispose method is called by the programmer. Dispose is

another method to release the memory used by an object. The Dispose method needs to be explicitly called in code to dereference an object from the heap. The Dispose

method can be invoked only by the classes that implement the IDisposable interface.

14. What is code access security (CAS)?

Code access security (CAS) is part of the .NET security model that prevents unauthorized access of resources and operations, and restricts the code to perform

particular tasks.

15. Differentiate between managed and unmanaged code?

Managed code is the code that is executed directly by the CLR instead of the operating system. The code compiler first compiles the managed code to intermediate

language (IL) code, also called as MSIL code. This code doesn't depend on machine configurations and can be executed on different machines.

Unmanaged code is the code that is executed directly by the operating system outside the CLR environment. It is directly compiled to native machine code which depends

on the machine configuration.
In the managed code, since the execution of the code is governed by CLR, the runtime provides different services, such as garbage collection, type checking, exception

handling, and security support. These services help provide uniformity in platform and language-independent behavior of managed code applications. In the unmanaged

code, the allocation of memory, type safety, and security is required to be taken care of by the developer. If the unmanaged code is not properly handled, it may

result in memory leak. Examples of unmanaged code are ActiveX components and Win32 APIs that execute beyond the scope of native CLR.

16. What are tuples?

Tuple is a fixed-size collection that can have elements of either same or different data types. Similar to arrays, a user must have to specify the size of a tuple at

the time of declaration. Tuples are allowed to hold up from 1 to 8 elements and if there are more than 8 elements, then the 8th element can be defined as another

tuple. Tuples can be specified as parameter or return type of a method.

17. How can you turn-on and turn-off CAS?

YOU can use the Code Access Security Tool (Caspol.exe) to turn security on and off.

To turn off security, type the following command at the command prompt:
caspol -security off

To turn on security, type the following command at the command prompt:
caspol -security on

In the .NET Framework 4.0, for using Caspol.exe, you first need to set the <LegacyCasPolicy> element to true.

18. What is garbage collection? Explain the difference between garbage collections in .NET 4.0 and earlier versions.

Garbage collection prevents memory leaks during execution of programs. Garbage collector is a low-priority process that manages the allocation and deallocation of

memory for your application. It checks for the unreferenced variables and objects. If GC finds any object that is no longer used by the application, it frees up the

memory from that object.

GC has changed a bit with the introduction of .NET 4.0. In .NET 4.0, the GC.Collect() method contains the following overloaded methods:
GC.Collect(int)
GC.Collect(int, GCCollectionMode)

Another new feature introduced in .NET is to notify you when the GC.Collect() method is invoked and completed successfully by using different methods. The .NET 4.0

supports a new background garbage collection that replaces the concurrent garbage collection used in earlier versions. This concurrent GC allocates memory while

running and uses current segment (which is 16 MB on a workstation) for that. After that, all threads are suspended. In case of background GC, a separate ephemeral GC -

gen0 and gen1 can be started, while the full GC - gen0, 1, and 2 - is already running.

19. How does CAS works?

There are two key concepts of CAS security policy- code groups and permissions. A code group contains assemblies in it in a manner that each .NET assembly is related

to a particular code group and some permissions are granted to each code group. For example, using the default security policy, a control downloaded from a Web site

belongs to the Zone, Internet code group, which adheres to the permissions defined by the named permission set. (Normally, the named permission set represents a very

restrictive range of permissions.)

Assembly execution involves the following steps:

Evidences are gathered about assembly.
Depending on the gathered evidences, the assembly is assigned to a code group.
Security rights are allocated to the assembly, depending on the code group.
Assembly runs as per the rights assigned to it.

20. What is Difference between NameSpace and Assembly?

Following are the differences between namespace and assembly:
Assembly is physical grouping of logical units, Namespace, logically groups classes.
Namespace can span multiple assembly.
21. Mention the execution process for managed code.

A piece of managed code is executed as follows:

Choosing a language compiler
Compiling the code to MSIL
Compiling MSIL to native code
Executing the code.

22. Is there a way to suppress the finalize process inside the garbage collector forcibly in .NET?

Use the GC.SuppressFinalize() method to suppress the finalize process inside the garbage collector forcibly in .NET.

23. How can you instantiate a tuple?

The following are two ways to instantiate a tuple:

Using the new operator. For example,
Tuple<String, int> t = new Tuple<String, int> ("Hellow", 2);
Using the Create factory method available in the Tuple class. For example,
Tuple<int, int, int> t = Tuple.Create<int, int, int> (2, 4, 5);

24. Which is the root namespace for fundamental types in .NET Framework?

System.Object is the root namespace for fundamental types in .NET Framework.

25. What are the improvements made in CAS in .NET 4.0?

The CAS mechanism in .NET is used to control and configure the ability of managed code. Earlier, as this policy was applicable for only native applications, the

security guarantee was limited. Therefore, developers used to look for alternating solutions, such as operating system-level solutions. This problem was solved in .NET

Framework 4 by turning off the machine-wide security. The shared and hosted Web applications can now run more securely. The security policy in .NET Framework 4 has

been simplified using the transparency model. This model allows you to run the Web applications without concerning about the CAS policies.

As a result of security policy changes in .NET Framework 4.0, you may encounter compilation warnings and runtime exceptions, if your try to use the obsolete CAS policy

types and members either implicitly or explicitly. However, you can avoid the warnings and errors by using the <NetFx40_LegacySecurityPolicy> configuration element in

the runtime settings schema to opt into the obsolete CAS policy behavior.

26. What is Microsoft Intermediate Language (MSIL)?

The .NET Framework is shipped with compilers of all .NET programming languages to develop programs. There are separate compilers for the Visual Basic, C#, and Visual

C++ programming languages in .NET Framework. Each .NET compiler produces an intermediate code after compiling the source code. The intermediate code is common for all

languages and is understandable only to .NET environment. This intermediate code is known as MSIL.

27. What is lazy initialization?

Lazy initialization is a process by which an object is not initialized until it is first called in your code. The .NET 4.0 introduces a new wrapper class,

System.Lazy<T>, for executing the lazy initialization in your application. Lazy initialization helps you to reduce the wastage of resources and memory requirements to

improve performance. It also supports thread-safety.

28. How many types of generations are there in a garbage collector?

Memory management in the CLR is divided into three generations that are build up by grouping memory segments. Generations enhance the garbage collection performance.

The following are the three types of generations found in a garbage collector:
Generation 0 - When an object is initialized, it is said to be in generation 0.
Generation 1 - The objects that are under garbage collection process are considered to be in generation 1.
Generation 2 - Whenever new objects are created and added to the memory, they are added to generation 0 and the old objects in generation 1 are considered to be in

generation 2.

29. Explain covariance and contra-variance in .NET Framework 4.0. Give an example for each.

In .NET 4.0, the CLR supports covariance and contravariance of types in generic interfaces and delegates. Covariance enables you to cast a generic type to its base

types, that is, you can assign a instance of type IEnumerable<Tl> to a variable of type IEnumerable<T2> where, T1 derives from T2. For example,

IEnumerable<string> str1= new List<string> ();
IEnumerable<object> str2= str1;

Contravariance allows you to assign a variable of Action<base> to a variable of type Action<derived>. For example,
IComparer<object> obj1 = GetComparer()
IComparer<string> obj2 = obj1;

.NET framework 4.0 uses some language keywords (out and in) to annotate covariance and contra-variance. Out is used for covariance, while in is used for contra-

variance.

Variance can be applied only to reference types, generic interfaces, and generic delegates. These cannot be applied to value types and generic types.

30. How do you instantiate a complex number?

The following are the different ways to assign a value to a complex number:

By passing two Double values to its constructor. The first value represents the real, and the second value represents imaginary part of a complex number.
For example,
Complex c1 = new Complex(5, 8); /* It represents (5, 8) */

By assigning a Byte, SByte, Intl6, UIntl6, Int32, UInt32, Int64, UInt64, Single, or Double value to a Complex object. The assigned value represents the real part of

the complex number, and its imaginary part becomes 0. For example,
Complex c2 = 15.3; /* It represents (15.3, 0) */

By casting a Decimal or BigInteger value to a Complex object.
For example,
Complex c3 = (Complex) 14.7; /* It represents (14.7, 0) */

Assigning the value returned by an operator to a Complex variable.
For example,
Complex c4 = c1 + c2; /* It represents (20.3, 8) */

31. What is Common Language Specification (CLS)?

CLS is a set of basic rules, which must be followed by each .NET language to be a .NET- compliant language. It enables interoperability between two .NET-compliant languages. CLS is a subset of CTS; therefore, the languages supported by CLS can use each other's class libraries similar to their own. Application programming interfaces (APIs), which are designed by following the rules defined in CLS can be used by all .NET-compliant languages.

32. What is the role of the JIT compiler in .NET Framework?

The JIT compiler is an important element of CLR, which loads MSIL on target machines for execution. The MSIL is stored in .NET assemblies after the developer has compiled the code written in any .NET-compliant programming language, such as Visual Basic and C#.

JIT compiler translates the MSIL code of an assembly and uses the CPU architecture of the target machine to execute a .NET application. It also stores the resulting native code so that it is accessible for subsequent calls. If a code executing on a target machine calls a non-native method, the JIT compiler converts the MSIL of that method into native code. JIT compiler also enforces type-safety in runtime environment of .NET Framework. It checks for the values that are passed to parameters of any method.

For example, the JIT compiler detects any event, if a user tries to assign a 32-bit value to a parameter that can only accept 8-bit value.

33. What is difference between System.String and System.StringBuilder classes?

String and StringBuilder classes are used to store string values but the difference in them is that String is immutable (read only) by nature, because a value once assigned to a String object cannot be changed after its creation. When the value in the String object is modified, a new object is created, in memory, with a new value assigned to the String object. On the other hand, the StringBuilder class is mutable, as it occupies the same space even if you change the value. The StringBuilder class is more efficient where you have to perform a large amount of string manipulation.

34. Describe the roles of CLR in .NET Framework.

CLR provides an environment to execute .NET applications on target machines. CLR is also a common runtime environment for all .NET code irrespective of their programming language, as the compilers of respective language in .NET Framework convert every source code into a common language known as MSIL or IL (Intermediate Language).

CLR also provides various services to execute processes, such as memory management service and security services. CLR performs various tasks to manage the execution process of .NET applications.

The responsibilities of CLR are listed as follows:

Automatic memory management
Garbage Collection
Code Access Security
Code verification
JIT compilation of .NET code

35. What is the difference between int and int32.

There is no difference between int and int32. System.Int32 is a .NET Class and int is an alias name for System.Int32.

Sunday, December 14, 2014

Java Interview Questions Part 2.


Q: What are the supported platforms by Java Programming Language?
A: Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc.

Q: List any five features of Java?
A: Some features include Object Oriented, Platform Independent, Robust, Interpreted, Multi-threaded

Q: Why is Java Architectural Neutral?
A: It’s compiler generates an architecture-neutral object file format, which makes the compiled code to be executable on many processors, with the presence of Java runtime system.

Q: How Java enabled High Performance?
A: Java uses Just-In-Time compiler to enable high performance. Just-In-Time compiler is a program that turns Java bytecode, which is a program that contains instructions that must be interpreted into instructions that can be sent directly to the processor.

Q: Why Java is considered dynamic?
A: It is designed to adapt to an evolving environment. Java programs can carry extensive amount of run-time information that can be used to verify and resolve accesses to objects on run-time.

Q: What is Java Virtual Machine and how it is considered in context of Java’s platform independent feature?
A: When Java is compiled, it is not compiled into platform specific machine, rather into platform independent byte code. This byte code is distributed over the web and interpreted by virtual Machine (JVM) on whichever platform it is being run.

Q: List two Java IDE’s?
A: Netbeans, Eclipse, etc.

Q: List some Java keywords(unlike C, C++ keywords)?
A: Some Java keywords are import, super, finally, etc.

Q: What do you mean by Object?
A: Object is a runtime entity and it’s state is stored in fields and behavior is shown via methods. Methods operate on an object's internal state and serve as the primary mechanism for object-to-object communication.

Q: Define class?
A: A class is a blue print from which individual objects are created. A class can contain fields and methods to describe the behavior of an object.

Q: What kind of variables a class can consist of?
A: A class consist of Local variable, instance variables and class variables.

Q: What is a Local Variable
A: Variables defined inside methods, constructors or blocks are called local variables. The variable will be declared and initialized within the method and it will be destroyed when the method has completed.

Q: What is a Instance Variable
A: Instance variables are variables within a class but outside any method. These variables are instantiated when the class is loaded.

Q: What is a Class Variable
A: These are variables declared with in a class, outside any method, with the static keyword.

Q: What is Singleton class?
A: Singleton class control object creation, limiting the number to one but allowing the flexibility to create more objects if the situation changes.

Q: What do you mean by Constructor?
A: Constructor gets invoked when a new object is created. Every class has a constructor. If we do not explicitly write a constructor for a class the java compiler builds a default constructor for that class.

Q: List the three steps for creating an Object for a class?
A: An Object is first declared, then instantiated and then it is initialized.

Q: What is the default value of byte datatype in Java?
A: Default value of byte datatype is 0.

Q: What is the default value of float and double datatype in Java?
A: Default value of float and double datatype in different as compared to C/C++. For float its 0.0f and for double it’s 0.0d

Q: When a byte datatype is used?
A: This data type is used to save space in large arrays, mainly in place of integers, since a byte is four times smaller than an int.

Q: What is a static variable?
A: Class variables also known as static variables are declared with the static keyword in a class, but outside a method, constructor or a block.

Q: What do you mean by Access Modifier?
A: Java provides access modifiers to set access levels for classes, variables, methods and constructors. A member has package or default accessibility when no accessibility modifier is specified.

Q: What is protected access modifier?
A: Variables, methods and constructors which are declared protected in a superclass can be accessed only by the subclasses in other package or any class within the package of the protected members' class.

Q: What do you mean by synchronized Non Access Modifier?
A: Java provides these modifiers for providing functionalities other than Access Modifiers, synchronized used to indicate that a method can be accessed by only one thread at a time.

Q: According to Java Operator precedence, which operator is considered to be with highest precedence?
A: Postfix operators i.e () [] . is at the highest precedence.

Q: Variables used in a switch statement can be used with which datatypes?
A: Variables used in a switch statement can only be a byte, short, int, or char.

Q: When parseInt() method can be used?
A: This method is used to get the primitive data type of a certain String.

Q: Why is String class considered immutable?
A: The String class is immutable, so that once it is created a String object cannot be changed. Since String is immutable it can safely be shared between many threads ,which is considered very important for multithreaded programming.

Q: Why is StringBuffer called mutable?
A: The String class is considered as immutable, so that once it is created a String object cannot be changed. If there is a necessity to make alot of modifications to Strings of characters then StringBuffer should be used.

Q: What is the difference between StringBuffer and StringBuilder class?
A: Use StringBuilder whenever possible because it is faster than StringBuffer. But, if thread safety is necessary then use StringBuffer objects.

Q: Which package is used for pattern matching with regular expressions?
A: java.util.regex package is used for this purpose.

Q: java.util.regex consists of which classes?
A: java.util.regex consists of three classes: Pattern class, Matcher class and PatternSyntaxException class.

Q: What is finalize() method?
A: It is possible to define a method that will be called just before an object's final destruction by the garbage collector. This method is called finalize( ), and it can be used to ensure that an object terminates cleanly.

Q: What is an Exception?
A: An exception is a problem that arises during the execution of a program. Exceptions are caught by handlers positioned along the thread's method invocation stack.

Q: What do you mean by Checked Exceptions?
A: It is an exception that is typically a user error or a problem that cannot be foreseen by the programmer. For example, if a file is to be opened, but the file cannot be found, an exception occurs. These exceptions cannot simply be ignored at the time of compilation.

Q: Explain Runtime Exceptions?
A: It is an exception that occurs that probably could have been avoided by the programmer. As opposed to checked exceptions, runtime exceptions are ignored at the time of compliation.

Q: Which are the two subclasses under Exception class?
A: The Exception class has two main subclasses : IOException class and RuntimeException Class.

Q: When throws keyword is used?
A: If a method does not handle a checked exception, the method must declare it using the throwskeyword. The throws keyword appears at the end of a method's signature.

Q: When throw keyword is used?
A: An exception can be thrown, either a newly instantiated one or an exception that you just caught, by using throw keyword.

Q: How finally used under Exception Handling?
A: The finally keyword is used to create a block of code that follows a try block. A finally block of code always executes, whether or not an exception has occurred.

Q: What things should be kept in mind while creating your own exceptions in Java?
A: While creating your own exception:

All exceptions must be a child of Throwable.

If you want to write a checked exception that is automatically enforced by the Handle or Declare Rule, you need to extend the Exception class.

You want to write a runtime exception, you need to extend the RuntimeException class.

Q: Define Inheritance?
A: It is the process where one object acquires the properties of another. With the use of inheritance the information is made manageable in a hierarchical order.

Q: When super keyword is used?
A: If the method overrides one of its superclass's methods, overridden method can be invoked through the use of the keyword super. It can be also used to refer to a hidden field

Q: What is Polymorphism?
A: Polymorphism is the ability of an object to take on many forms. The most common use of polymorphism in OOP occurs when a parent class reference is used to refer to a child class object.

Q: What is Abstraction?
A: It refers to the ability to make a class abstract in OOP. It helps to reduce the complexity and also improves the maintainability of the system.

Q: What is Abstract class?
A: These classes cannot be instantiated and are either partially implemented or not at all implemented. This class contains one or more abstract methods which are simply method declarations without a body.

Q: When Abstract methods are used?
A: If you want a class to contain a particular method but you want the actual implementation of that method to be determined by child classes, you can declare the method in the parent class as abstract.

Q: What is Encapsulation?
A: It is the technique of making the fields in a class private and providing access to the fields via public methods. If a field is declared private, it cannot be accessed by anyone outside the class, thereby hiding the fields within the class. Therefore encapsulation is also referred to as data hiding.

Q: What is the primary benefit of Encapsulation?
A: The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this Encapsulation gives maintainability, flexibility and extensibility to our code.

Q: What is an Interface?
A: An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.

Q: Give some features of Interface?
A: It includes:

Interface cannot be instantiated

An interface does not contain any constructors.

All of the methods in an interface are abstract.

Q: Define Packages in Java?
A: A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and name space management.

Q: Why Packages are used?
A: Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations, etc., easier.

Q: What do you mean by Multithreaded program?
A: A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.

Q: What are the two ways in which Thread can be created?
A: Thread can be created by: implementing Runnable interface, extending the Thread class.

Q: What is an applet?
A: An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its disposal.

Q: An applet extend which class?
A: An applet extends java.applet.Applet class.

Q: Explain garbage collection in Java?
A: It uses garbage collection to free the memory. By cleaning those objects that is no longer reference by any of the program.

Q: Define immutable object?
A: An immutable object can’t be changed once it is created.

Q: Explain the usage of this() with constructors?
A: It is used with variables or methods and used to call constructer of same class.

Q: Explain Set Interface?
A: It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.

Q: Explain TreeSet?
A: It is a Set implemented when we want elements in a sorted order.

Q: What is Comparable Interface?
A: It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.

Q: Difference between throw and throws?
A: It includes:

Throw is used to trigger an exception where as throws is used in declaration of exception.

Without throws, Checked exception cannot be handled where as checked exception can be propagated with throws.

Q: Explain the following line used under Java Program:
public static void main (String args[ ])

A: The following shows the explanation individually:

public: it is the access specifier.

static: it allows main() to be called without instantiating a particular instance of a class.

void: it affirns the compiler that no value is returned by main().

main(): this method is called at the beginning of a Java program.

String args[ ]: args parameter is an instance array of class String

Q: Define JRE i.e. Java Runtime Environment?
A: Java Runtime Environment is an implementation of the Java Virtual Machine which executes Java programs. It provides the minimum requirements for executing a Java application;

Q: What is JAR file?
A: JAR files is Java Archive fles and it aggregates many files into one. It holds Java classes in a library. JAR files are built on ZIP file format and have .jar file extension.

Q: What is a WAR file?
A: This is Web Archive File and used to store XML, java classes, and JavaServer pages. which is used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, static Web pages etc.

Q: Define JIT compiler?
A: It improves the runtime performance of computer programs based on bytecode.

Q: What is the difference between object oriented programming language and object based programming language?
A: Object based programming languages follow all the features of OOPs except Inheritance. JavaScript is an example of object based programming languages

Q: What is the purpose of default constructor?
A: The java compiler creates a default constructor only if there is no constructor in the class.

Q: Can a constructor be made final?
A: No, this is not possible.

Q: What is static block?
A: It is used to initialize the static data member, It is excuted before main method at the time of classloading.

Q: Define composition?
A: Holding the reference of the other class within some other class is known as composition.

Q: What is function overloading?
A: If a class has multiple functions by same name but different parameters, it is known as Method Overloading.

Q: What is function overriding?
A: If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding.

Q: Difference between Overloading and Overriding?
A: Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class parameter must be different in case of overloading, parameter must be same in case of overriding.

Q: What is final class?
A: Final classes are created so the methods implemented by that class cannot be overridden. It can’t be inherited.

Q: What is NullPointerException?
A: A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc.

Q: What are the ways in which a thread can enter the waiting state?
A: A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object's lock, or by invoking an object's wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

Q: How does multi-threading take place on a computer with a single CPU?
A: The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

Q: What invokes a thread's run() method?
A: After a thread is started, via its start() method of the Thread class, the JVM invokes the thread's run() method when the thread is initially executed.

Q: Does it matter in what order catch statements for FileNotFoundException and IOException are written?
A: Yes, it does. The FileNoFoundException is inherited from the IOException. Exception's subclasses have to be caught first.

Q: What is the difference between yielding and sleeping?
A: When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

Q: Why Vector class is used?
A: The Vector class provides the capability to implement a growable array of objects. Vector proves to be very useful if you don't know the size of the array in advance, or you just need one that can change sizes over the lifetime of a program.

Q: How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
A: Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

Q: What are Wrapper classes?
A: These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.

Q: What is the difference between a Window and a Frame?
A: The Frame class extends Window to define a main application window that can have a menu bar.

Q: Which package has light weight components?
A: javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.

Q: What is the difference between the paint() and repaint() methods?
A: The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

Q: What is the purpose of File class?
A: It is used to create objects that provide access to the files and directories of a local file system.

Q: What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
A: The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

Q: Which class should you use to obtain design information about an object?
A: The Class class is used to obtain information about an object's design and java.lang.Class class instance represent classes, interfaces in a running Java application.

Q: What is the difference between static and non-static variables?
A: A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.

Q: What is Serialization and deserialization?
A: Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

Q: What are use cases?
A: It is part of the analysis of a program and describes a situation that a program might encounter and what behavior the program should exhibit in that circumstance.

Q: Explain the use of sublass in a Java program?
A: Sub class inherits all the public and protected methods and the implementation. It also inherits all the default modifier methods and their implementation.

Q: How to add menushortcut to menu item?
A: If there is a button instance called b1, you may add menu short cut by calling b1.setMnemonic('F'), so the user may be able to use Alt+F to click the button.

Q: Can you write a Java class that could be used both as an applet as well as an application?
A: Yes, just add a main() method to the applet.

Q: What is the difference between Swing and AWT components?
A: AWT components are heavy-weight, whereas Swing components are lightweight. Heavy weight components depend on the local windowing toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button.

Q: What's the difference between constructors and other methods?
A: Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

Q: Is there any limitation of using Inheritance?
A: Yes, since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation.

Q: When is the ArrayStoreException thrown?
A: When copying elements between different arrays, if the source or destination arguments are not arrays or their types are not compatible, an ArrayStoreException will be thrown.

Q: Can you call one constructor from another if a class has multiple constructors?
A: Yes, use this() syntax.

Q: What's the difference between the methods sleep() and wait()?
A: The code sleep(2000); puts thread aside for exactly two seconds. The code wait(2000), causes a wait of up to two second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

Q: When ArithmeticException is thrown?
A: The ArithmeticException is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating-point operations.

Q: What is a transient variable?
A: A transient variable is a variable that may not be serialized during Serialization and which is initialized by its default value during de-serialization,

Q: What is synchronization?
A: Synchronization is the capability to control the access of multiple threads to shared resources. synchronized keyword in java provides locking which ensures mutual exclusive access of shared resource and prevent data race.

Q: What is the Collections API?
A: The Collections API is a set of classes and interfaces that support operations on collections of objects.

Q: Does garbage collection guarantee that a program will not run out of memory?
A: Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

Q: The immediate superclass of the Applet class?
A: Panel is the immediate superclass. A panel provides space in which an application can attach any other component, including other panels.

Q: Which Java operator is right associative?
A: The = operator is right associative.

Q: What is the difference between a break statement and a continue statement?
A: A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.

Q: If a variable is declared as private, where may the variable be accessed?
A: A private variable may only be accessed within the class in which it is declared.

Q: What is the purpose of the System class?
A: The purpose of the System class is to provide access to system resources.

Q: List primitive Java types?
A: The eight primitive types are byte, char, short, int, long, float, double, and boolean.

Q: What is the relationship between clipping and repainting under AWT?
A: When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.

Q: Which class is the immediate superclass of the Container class?
A: Component class is the immediate super class.

Q: What class of exceptions are generated by the Java run-time system?
A: The Java runtime system generates RuntimeException and Error exceptions.

Q: Under what conditions is an object's finalize() method invoked by the garbage collector?
A: The garbage collector invokes an object's finalize() method when it detects that the object has become unreachable.

Q: How can a dead thread be restarted?
A: A dead thread cannot be restarted.

Q: Which arithmetic operations can result in the throwing of an ArithmeticException?
A: Integer / and % can result in the throwing of an ArithmeticException.

Q: Variable of the boolean type is automatically initialized as?
A: The default value of the boolean type is false.

Q: Can try statements be nested?
A: Yes

Q: What are ClassLoaders?
A: A class loader is an object that is responsible for loading classes. The class ClassLoader is an abstract class.

Q: What is the difference between an Interface and an Abstract class?
A: An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all methods are implicitly abstract. An interface has all public members and no implementation.

Q: What will happen if static modifier is removed from the signature of the main method?
A: Program throws "NoSuchMethodError" error at runtime .

Q: What is the default value of an object reference declared as an instance variable?
A: Null, unless it is defined explicitly.

Q: Can a top level class be private or protected?
A: No, a top level class can not be private or protected. It can have either "public" or no modifier.

Q: Why do we need wrapper classes?
A: We can pass them around as method parameters where a method expects an object. It also provides utility methods.

Q: What is the difference between error and an exception?
A: An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. Exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be thrown if the specified file does not exist.

Q: Is it necessary that each try block must be followed by a catch block?
A: It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.

Q: When a thread is created and started, what is its initial state?
A: A thread is in the ready state as initial state after it has been created and started.

Q: What is the Locale class?
A: The Locale class is used to tailor program output to the conventions of a particular geographic, political, or cultural region.

Q: What are synchronized methods and synchronized statements?
A: Synchronized methods are methods that are used to control access to an object. A synchronized statement can only be executed after a thread has acquired the lock for the object or class referenced in the synchronized statement.

Q: What is runtime polymorphism or dynamic method dispatch?
A: Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method is called through the reference variable of a superclass.

Q: What is Dynamic Binding(late binding)?
A: Binding refers to the linking of a procedure call to the code to be executed in response to the call. Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.

Q: Can constructor be inherited?
A: No, constructor cannot be inherited.

Q: What are the advantages of ArrayList over arrays?
A: ArrayList can grow dynamically and provides more powerful insertion and search mechanisms than arrays.

Q: Why deletion in LinkedList is fast than ArrayList?
A: Deletion in linked list is fast because it involves only updating the next pointer in the node before the deleted node and updating the previous pointer in the node after the deleted node.

Q: How do you decide when to use ArrayList and LinkedList?
A: If you need to frequently add and remove elements from the middle of the list and only access the list elements sequentially, then LinkedList should be used. If you need to support random access, without inserting or removing elements from any place other than the end, then ArrayList should be used.

Q: What is a Values Collection View ?
A: It is a collection returned by the values() method of the Map Interface, It contains all the objects present as values in the map.

Q: What is dot operator?
A: The dot operator(.) is used to access the instance variables and methods of class objects.It is also used to access classes and sub-packages from a package.

Q: Where and how can you use a private constructor?
A: Private constructor is used if you do not want other classes to instantiate the object and to prevent subclassing.T

Q: What is type casting?
A: Type casting means treating a variable of one type as though it is another type.

Q: Describe life cycle of thread?
A: A thread is a execution in a program. The life cycle of a thread include:

Newborn state
Runnable state
Running state
Blocked state
Dead state
Q: What is the difference between the >> and >>> operators?
A: The >> operator carries the sign bit when shifting right. The >>> zero-fills bits that have been shifted out.

Q: Which method of the Component class is used to set the position and size of a component?
A: setBounds() method is used for this purpose.

Q: What is the range of the short type?
A: The range of the short type is -(2^15) to 2^15 - 1.

Q: What is the immediate superclass of Menu?
A: MenuItem class

Q: Does Java allow Default Arguments?
A: No, Java does not allow Default Arguments.

Q: Which number is denoted by leading zero in java?
A: Octal Numbers are denoted by leading zero in java, example: 06

Q: Which number is denoted by leading 0x or 0X in java?
A: Hexadecimal Numbers are denoted by leading 0x or 0X in java, example: 0XF

Q: Break statement can be used as labels in Java?
A: Yes, an example can be break one;

Q: Where import statement is used in a Java program?
A: Import statement is allowed at the beginning of the program file after package statement.

Q: Explain suspend() method under Thread class>
A: It is used to pause or temporarily stop the execution of the thread.

Q: Explain isAlive() method under Thread class?
A: It is used to find out whether a thread is still running or not.

Q: What is currentThread()?
A: It is a public static method used to obtain a reference to the current thread.

Q: Explain main thread under Thread class execution?
A: The main thread is created automatically and it begins to execute immediately when a program starts. It ia thread from which all other child threads originate.

Q: Life cycle of an applet includes which steps?
A: Life cycle involves the following steps:

Initialization

Starting

Stopping

Destroying

Painting

Q: Why is the role of init() method under applets?
A: It initializes the applet and is the first method to be called.

Q: Which method is called by Applet class to load an image?
A: getImage(URL object, filename) is used for this purpose.

Q: Define code as an attribute of Applet?
A: It is used to specify the name of the applet class.

Q: Define canvas?
A: It is a simple drawing surface which are used for painting images or to perform other graphical operations.

Q: Define Network Programming?
A: It refers to writing programs that execute across multiple devices (computers), in which the devices are all connected to each other using a network.

Q: What is a Socket?
A: Sockets provide the communication mechanism between two computers using TCP. A client program creates a socket on its end of the communication and attempts to connect that socket to a server.

Q: Advantages of Java Sockets?
A: Sockets are flexible and sufficient. Efficient socket based programming can be easily implemented for general communications. It cause low network traffic.

Q: Disadvantages of Java Sockets?
A: Socket based communications allows only to send packets of raw data between applications. Both the client-side and server-side have to provide mechanisms to make the data useful in any way.

Q: Which class is used by server applications to obtain a port and listen for client requests?
A: java.net.ServerSocket class is used by server applications to obtain a port and listen for client requests

Q: Which class represents the socket that both the client and server use to communicate with each other?
A: java.net.Socket class represents the socket that both the client and server use to communicate with each other.

Q: Why Generics are used in Java?
A: Generics provide compile-time type safety that allows programmers to catch invalid types at compile time. Java Generic methods and generic classes enable programmers to specify, with a single method declaration, a set of related methods or, with a single class declaration, a set of related types.

Q: What environment variables do I need to set on my machine in order to be able to run Java programs?
A: CLASSPATH and PATH are the two variables.

Q: Is there any need to import java.lang package?
A: No, there is no need to import this package. It is by default loaded internally by the JVM.

Q: What is Nested top-level class?
A: If a class is declared within a class and specify the static modifier, the compiler treats the class just like any other top-level class. Nested top-level class is an Inner class.

Q: What is Externalizable interface?
A: Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism.

Q: If System.exit (0); is written at the end of the try block, will the finally block still execute?
A: No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never executes.

Q: What is daemon thread?
A: Daemon thread is a low priority thread, which runs intermittently in the back ground doing the garbage collection operation for the java runtime system.

Q: Which method is used to create the daemon thread?
A: setDaemon method is used to create a daemon thread.

Q: Which method must be implemented by all threads?
A: All tasks must implement the run() method

Q: What is the GregorianCalendar class?
A: The GregorianCalendar provides support for traditional Western calendars

Q: What is the SimpleTimeZone class?
A: The SimpleTimeZone class provides support for a Gregorian calendar .

Q: What is the difference between the size and capacity of a Vector?
A: The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time.

Q: Can a vector contain heterogenous objects?
A: Yes a Vector can contain heterogenous objects. Because a Vector stores everything in terms of Object.

Q: What is an enumeration?
A: An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection.

Q: What is difference between Path and Classpath?
A: Path and Classpath are operating system level environment variales. Path is defines where the system can find the executables(.exe) files and classpath is used to specify the location of .class files.

Q: Can a class declared as private be accessed outside it's package?
A: No, it's not possible to accessed outside it's package.

Q: What are the restriction imposed on a static method or a static block of code?
A: A static method should not refer to instance variables without creating an instance and cannot use "this" operator to refer the instance.

Q: Can an Interface extend another Interface?
A: Yes an Interface can inherit another Interface, for that matter an Interface can extend more than one Interface.

Q: Which object oriented Concept is achieved by using overloading and overriding?
A: Polymorphism

Q: What is an object's lock and which object's have locks?
A: An object's lock is a mechanism that is used by multiple threads to obtain synchronized access to the object. A thread may execute a synchronized method of an object only after it has acquired the object's lock.

Q: What is Downcasting?
A: It is the casting from a general to a more specific type, i.e. casting down the hierarchy.

Q: What are order of precedence and associativity and how are they used?
A: Order of precedence determines the order in which operators are evaluated in expressions. Associatity determines whether an expression is evaluated left-to-right or right-to-left.

Q: If a method is declared as protected, where may the method be accessed?
A: A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

Q: What is the difference between inner class and nested class?
A: When a class is defined within a scope of another class, then it becomes inner class. If the access modifier of the inner class is static, then it becomes nested class.

Q: What restrictions are placed on method overriding?
A: Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides.

Q: What is constructor chaining and how is it achieved in Java?
A: A child object constructor always first needs to construct its parent. In Java it is done via an implicit call to the no-args constructor as the first statement.

Q: Can a double value be cast to a byte?
A: Yes, a double value can be cast to a byte.

Q: How does a try statement determine which catch clause should be used to handle an exception?
A: When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first catch clause that is capable of handling the exception is executed. The remaining catch clauses are ignored.

Q: What will be the default values of all the elements of an array defined as an instance variable?
A: If the array is an array of primitive types, then all the elements of the array will be initialized to the default value corresponding to that primitive type.