JAVA INTERVIEW QUESTIONS EBOOK
INTRODUCTION: Tricky Java Interview Questions. This book contains tricky and nasty Java interview questions that an interviewer asks in Java technology. Buy JAVA INTERVIEW QUESTIONS by DAMYANTI PATHAK (eBook) online at Lulu. Visit the Lulu Marketplace for product details, ratings, and. Buy Java Interview Questions by Damyanti Pathak (eBook) online at Lulu. Visit the Lulu Marketplace for product details, ratings, and reviews.
|Language:||English, Spanish, Arabic|
|ePub File Size:||23.31 MB|
|PDF File Size:||17.17 MB|
|Distribution:||Free* [*Regsitration Required]|
I was getting a lot of emails and comments to create java interview questions and answers PDF eBook. It was hard and time taking, but finally, it's done. This book is targeted only on JAVA Interview and contains a smaller subset of the thousand interesting Java interview questions. This book is. salelive.info: Java Interview Questions & Answers eBook: Venkatesh: Kindle Store.
I was getting a lot of emails and comments to create java interview questions and answers PDF eBook. Below image shows the cover page of this eBook. Just subscribe to my newsletter and you will get this eBook first thing in the email. Bonus eBook: For a short time, I am giving the direct download for all my newsletter subscribers to my Java Design Patterns PDF eBook that has been downloaded over 50, times.
You can even play with java internal codes for fun, and millions of community people would help you with your programming issues. Cool first language: Java is one of the best languages to start programming with. Java is object oriented: Java has quite an extraordinary strength in code structure and design. Object Oriented code is one of the most demanded skills that any programmer must master, and java clearly helps us achieve that.
Java runs everywhere: Java is a compiled as well as an interpreted language. So this byte code is interpreted by the JVM to give you your desired output.
JVM itself is platform dependent, i. Page Java Interview Java is simple and safe: Java is Growing Internet and Mobiles: Java is no longer a language which is limited to traditional desktop programming etc. The Android mobile platform is based on java which shows us the power of the language. Java itself has its J2ME platform for mobile applications too. Some other Facts about Java: OOP gives a structure to your code, makes it more modulated, easy to reuse and most importantly it keeps your code simple.
Here are the chief OOP concepts we would use in our everyday coding: Classes and Objects: The entry point into OOP world is class and objects. Inheritance enables code reuse in our programs, where any child class gets all the extendable code from its parent, exactly similar how the word inheritance itself works.
Its like one thing taking multiple forms, capable of doing multiple tasks. There are two kinds of Polymorphism supported by java, Static Polymorphism Compile time polymorphism and Dynamic Polymorphism Runtime polymorphism. Method Overloading is an example of compile time polymorphism; whereas Method Overriding is an example of runtime polymorphism in java. Abstraction says about extracting out the complex details and exposing out the necessary details i. Abstraction therefore gives a blue print of an idea, and concrete implementations would later be built over it.
The code is later build on top of it. Below is an example of an Abstract class providing only the most general definitions without talking anything about how are we ever going to achieve it via code: Encapsulation — Encapsulation is simple, as simple as its name is.
Encapsulation simply says about putting all things in a capsule, exactly what we do while creating Java classes. People also tend to confuse Encapsulation with Data Hiding. Well everything that is encapsulated may not be hidden. But yes encapsulation can be used to achieve Data Hiding also, by adding private methods or fields etc. Encapsulation only proposes to keep similar things together in a capsule.
Below is a simple example of encapsulation: IS-A is denotes an Inheritance relation between two entities. IS-A is used to specify a more specific type of the entity.
Where the parent classes Animal and SuperHero are more general, we have more specific subclasses Dog and Superman. The concept of IS-A is all about Inheritance.
HAS-A Relationship: The Animal can be considered an instance variable inside the Zoo class. USES-A is a simple relationship where one entity is not related to the other entity but just wants to use it for some purpose. The questions in this section are of intermediate level and you must be very thorough with almost all of these questions.
Also not to mention there can be many more questions so emphasize on the concepts instead of trying to memorize the code. Do not be scared with the quantity of questions in the section, you might actually be knowing the answers to most of the questions in the section already, so you just have to skim through the questions in that case.
But, if the questions appear new or different please try the Code Snippet given with the explanations. Typing the code might take a few minutes but you would really be able to understand how the code behaves.
We cannot learn Coding until we Code. A Point blank answer can be -: Abstract class: An abstract class is a class which may have some unimplemented methods along with some implemented methods. An abstract class can have non-final instance variables, and can be extended by any concrete or abstract class.
The extending class must implement all the un-implemented methods or has to be an abstract class itself. Abstract class can have constructors, but they cannot be directly instantiated. An interface cannot have any implemented methods, only method signature falls in interface. Interface cannot have a private method. Any instance variable in interface has to be final. Interfaces can neither be instantiated, nor can they have constructors.
Explain Synchronization and Multithreading. Traditionally all our programs run only on a single thread main thread and the thread completes when the sequential execution of code is over. Java permits Multi-Threading, where we can have more than one threads, each executing an independent module of its own to gain parallelization in the code, making it efficient.
Then comes the problem of shared resource. When we have multiple threads in our program, and we have a particular variable or piece of code which works on a sensitive data. Java has a synchronized keyword and a synchronized block to avoid this issue. Any method marked synchronized becomes thread safe and can be accessed only by one thread at a time; similarly any block of code inside the synchronized block becomes thread safe and only one thread can be inside that block at a time. Threads are integral part of many applications which seek better performance and are extensively used in the IT industry.
People would definitely need you to know the In-Outs of threads, if not at least the basics in place. These are the steps you need to follow to make your class Threaded and run your thread: Making Your Class Threaded This can be done by two ways, either by extending the Thread class or by implementing the Runnable Interface.
Below is a short note on both the approaches: Extending the thread class: One way of making you class a threaded class is extending the Thread class. Extending Runnable Interface: This is another way of making your class threaded. Implementing Runnable interface on the other hand does not stop us from extending an parent class, hence gives a programming advantage over Thread Class.
This is the primary method which Java Interview Anything that comes into this method is run as a new thread by the JVM. Create a thread object and start the new thread Now since we have our thread class ready, we can create an object of the class from anywhere, within the class or outside in another class, and just have to trigger the start method to start our thread. It is important to use the threadObj. The run method is internally called by the JVM to create a thread and execute the code you provided, directly calling the run method executes you code sequentially as any ordinary method would do.
Related question: Which is better, extending the Thread class or implementing the Runnable Interface? Here is a skeleton showing Threads in Action.
Pass by value and Pass by reference is an age old programming concept, where Pass by value passes only the value of a variable in a method call, where pass by reference passes the address of the variable via pointers to the method, hence any changes to the variable in the called function actually reflects the change in the called function. Java is Pass by Value, and does not support Pass by Reference.
Related Questions: Primitive data types are passed by reference or pass by value? Everything in java is passed by Value. Objects are passed by value or by reference?
Pass By Value, friends. Differentiate between HashMap and Map? HashMap itself is an unordered collection, and does not follow the order of insertion. HashMap internally uses the hashing algorithm and buckets to put objects in memory, and gives an O 1 time complexity for insertion and retrieval of values, hence has an clear advantage over the other Data Structures.
Differences between HashMap and HashTable? Preferred when we are not Thread Safe and Synchronized. Performance trade-off due to An equivalent thread safe map can be created by synchronization overhead. No guarantee over the order of insertion in HashMap. All the data is kept in the order of insertion in HashTables.
Suggested by Java. Differentiate between Vector and ArrayList? The Vector class was deprecated by Java when they introduced the ArrayList class. The differences between Vector and ArrayList are: Vector ArrayList Deprecated Class.
New implementation provided by Java.
The java interview questions ebook - confused coders
Thread safe and Synchronized. Un-Synchronized, thread unsafe. There is a little performance trade-off with Better performance than Vectors. Differentiate between Map and Set? Set holds unique values, whereas the Map holds unique Keys and can have any amount of duplicate Values assigned to the unique keys. Maps are part of java collection framework but do not extend the Collection Interface, Set is a part of collection framework and also extends Collection Interface.
Differentiate between AWT and Swing? What is the difference between a constructor and any ordinary method? Constructor is a special method that is used to initialize objects before we start using them. A constructor does not have a return type and has the same name as the class name itself. Java provides a default constructor to every class unless the programmer has defined any constructor himself. The default constructor enables us to create objects of our class by the line of code: What is an Iterator?
Iterator is just another java object that lets you iterate over an java collection.
How To Ace The Java Inverview Process
Yes you can always use our favorite foreach loop to scan over the collection, but sometimes we may need to modify the collection while in iteration, here the iterator comes to our rescue. We can remove the element from the iterator while being inside the iteration iterators are fail fast , the foreach loop would blow off in this situation with a ConcurrentModificationException. Again we must be clear that there are two obvious ways for accessing Java Interview Again there is a third way with static methods and static variables that can be accessed directly by the class name.
Now discussing about the access modifiers: This is the most relaxed access modifier. It is not available to any class extending it, nor can be accessed by objects of the class.
Outside the package protected access specified properties are only accessible via Inheritance. This is another restrictive access modifier. There is no way to access a default property outside the package. We insist you to type down the code below, and play with it to get your concepts in place.
Typing just two Java classes should not be a very difficult task. What is the significance of a static modifier? On a direct note: Everything is packed inside that little object in the Heap, and if we have 10 such objects created, each of these little objects would have their own properties and methods working on those properties, such that on modifying any property of the first object would have no effect on the other 9 objects.
So basically we have 10 people with their own data, and their own powers. Now say we need to have a data that needs to be shared across these 10 people, what do we do? Just for the information, the static data lands up in the Heap only — a special heap area known as perm heap or permanent generation , but not inside an object or the Heap where objects are present.
This area contains all static data of any class along with other metadata information. We would be talking a little over this in the third section of the book in the Java Memory Allocation question. Greedy for learning more? Go on, do some surfing over it, you might learn something totally awesome.
Different usage of static key word: Static variable: One per class, shared variable. Static Method: Belongs to class, similar to static variable.
It can access only static data and static methods directly. Else we need to create object of the class and call the methods from the object exactly what we do in our main method most of the times. A static method cannot use32 the this and super keyword inside itself. It can also be accessed via thePage ClassName. Java Interview Static Block: Your program can also have an interesting thing known as the static block. A static block is a piece of code which you want to execute before any part of your class is used.
A static blocks is the 1st thing that would be executed by the JVM, even before the constructor. The static block would be executed only once. Open your IDE and try this piece of code instantly and observe the order of execution: Anything that is marked final in java becomes final i. Page committed. A variable marked final cannot be changed by re-assigning any value to it again.
Any Java Interview And any class marked final cannot be extended by any other class. Can main method be declared as private? Why not, there is no compilation error for sure if my main method is private; but then I am not able to run my code.
Wondering why? Who calls our program.. Etc etc.. So it requests you — please provide me a main method which I can call. I would be treating this method as the entry point to your program. Now, How does the JVM make the method call?
Simple, it just uses the ClassName. So understanding this, we can now think that if the main is not public, how would it be visible to the JVM. What if the static modifier is removed from the main method signature? What if I do not provide the String array as the argument to the method? VM would again Fail, not being able to find the correct method.
What if I write static public void main, instead of public static void main? Its just fine. No issues here. What is the first argument of the String array in main method? It just holds the parameters provided to the program. If I do not provide any arguments on the command line, then the String array of Main method will be empty or null? How can we check if the argument array is empty or NULL? We can check it programmatically: Why not, just while executing you must specify the entry point class name, where it should look for the main method.
Generally it makes more sense to have only one main, since there should logically one entry point only in the applications.
So in case of multiple main application, while bundling the application the entry point has to be specified which the JVM would call to use the application.
Generally you would distribute your application as a JAR, and there you have to mention which class is going to be the entry point for the app. So even if you have multiple classes with multiple mains, The JVM knows which class to call. Related Question: Can I have multiple main methods in the same class? Yes, of course, all you are trying to do is overload the main method, so its all valid as long as they stand upto method overloading rules. Do we have to import java.
No, java. You can assume JVM does that for us. Yes, a package can be imported N- number of times without any issue. Instead package import is just a qualified name of the class, i. Math class. What are Checked and Un-Checked Exception?
Java Interview Questions and Answers PDF eBook Free Download (250+ Questions, 60 Pages)
The exceptions are broadly classified into two types: Below is the information that should be present in these notices. It is designed to make submitting notices of alleged infringement to us as straightforward as possible while reducing the number of notices that we receive that are fraudulent or difficult to understand or verify.
Copyright Office website, http: To file a notice of infringement with us, you must provide us with the items specified below. Please note that you will be liable for damages including costs and attorneys' fees if you materially misrepresent that the material is infringing your copyright. Accordingly, if you are not sure whether material infringes your copyright, we suggest that you first contact an attorney. This notice and any attachments we receive will be forwarded to the alleged infringer, who will then have the opportunity to file a counter notification pursuant to Sections g 2 and 3 of the DMCA.
Should a properly filed counter notification be filed, you will be notified and have 10 business days within which to file for a restraining order in Federal Court to prevent the reinstatement of the material.
All required fields must be filled out for us to be able to process your form. We help people distribute information and art spanning a wide range of subject matter while providing a safe, friendly, respectful, and serious site for all content creators.
Since our community serves a broad range of ages, we do not encourage content that could make a majority of our users uncomfortable. If you are sure that this product is in violation of acceptable content as defined in the agreement or that it does not meet our guidelines for General Access, please fill out the form below.
It will then be reviewed by Lulu Staff to determine the next course of action. Identify in sufficient detail the copyrighted work that you believe has been infringed upon for example, "The copyrighted work at issue is the image that appears on http: Identify each web page that allegedly contains infringing material. This requires you to provide the URL for each allegedly infringing result, document or item. I have a good faith belief that use of the copyrighted materials described above as allegedly infringing is not authorized by the copyright owner, its agent, or the law.
I swear, under penalty of perjury, that the information in the notification is accurate and that I am the copyright owner or am authorized to act on behalf of the owner of an exclusive right that is allegedly infringed. Your digital signature is as legally binding as a physical signature. If you use a digital signature, your signature must exactly match the First and Last names that you specified earlier in this form.
This form does not constitute legal advice and nothing that you read or are provided on this web site should be used as a substitute for the advice of competent legal counsel. If someone believes in good faith that a Lulu Account Holder has infringed their copyright, they can request that we take down the infringing material by filing a DMCA Notice.
When a clear and valid Notice is received pursuant to the guidelines, we will respond by either taking down the allegedly infringing content or blocking access to it, and we may also contact you for more information. If you are not the copyright holder or its agent and if the content is clearly infringing the copyright of a well-known work, please select "Infringes a well-known work" from the dropdown menu.
Lulu Staff has been notified of a possible violation of the terms of our Membership Agreement. Our agents will determine if the content reported is inappropriate or not based on the guidelines provided and will then take action where needed. Thank you for notifying us. The page you are attempting to access contains content that is not intended for underage readers. Useful book for people preparing for Java Interviews. How can I use this format?
Lulu Sales Rank: