Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
1K views

Java Interview Guide - Cracked - Sample

Crack any Java Interview with ease ! This book is to prepare you for the initial technical rounds for any Java Interview. It is a guide with concepts from real interview experiences of the author.

Uploaded by

AkhileshTrivedi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
1K views

Java Interview Guide - Cracked - Sample

Crack any Java Interview with ease ! This book is to prepare you for the initial technical rounds for any Java Interview. It is a guide with concepts from real interview experiences of the author.

Uploaded by

AkhileshTrivedi
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 15

1|Page Java Interview Guide - Cracked

Introduction
Interview preparation is an art in itself. There are many books and articles
have been written on the subject, my stand has been little different. It is “Inter-
view” so it means someone is going to look inside me. That way, I believe I must
be ready to showcase with ease, everything that is being searched inside me by
the person who is interviewing.

I expect my interviewers to be good listeners. If they are talking more


than me then it is not my interview rather theirs and I have seen such interviewers
are mostly the ones who do not see the positive in you but are those who would
respond like “we would get back to you” but are actually eagerly waiting to say “I
rejected him!”. Don’t get bothered about them, just consider that panel is wrong,
not you.

It is more than two decades now since Java was born, and the coffee is
still hot.  Many of us are into Java-line and have been switching jobs often;
many do this with ease while many struggle very hard. “Struggle” - Through this
book, I have made a small attempt to make this struggle thing easy. While this
book would act as a guide to cracking initial rounds of any Java interview; some
of you might also find it useful to gain knowledge on core-java concepts that are
little trickier.

My special thanks to those who have landed here from my Udemy course.
Thank you for following me.

Good luck!
2|Page Java Interview Guide - Cracked

Who this book is for?

This book is for the person who has some knowledge on Java and wish to
hold a strong grip further on the same; it is also for the people who are serious
about a java job, particularly into web development via the J2EE line. Many
people would call it all "bogus" and repetitive but I must tell you this is the core
of the core java. My course on Udemy (Java Interview Guide: Cracking the first
round) only had questions and this book is to complement the same for the
people who call it incomplete. If my udemy course was designed for the quick
brush up on a night before the java interview, this book has been phrased for a
good preparation well in advance.

Who this book is NOT for?


This is not an elementary course in java. This book is not for the people
wanting to begin learning java. I am not writing this book for a fresher or college
pass out, neither am I targeting this for a solution architect with more than a
decade of experience. It is neither the first gear nor the top gear rather it is the
speed where you will save most of your fuel.
3|Page Java Interview Guide - Cracked

Table of Contents
Introduction ........................................................................................................... 1
Who this book is for? ............................................................................................. 2
Who this book is NOT for? ..................................................................................... 2
Preparation ............................................................................................................ 6
Choosing a resume template ............................................................................. 6
Size of resume .................................................................................................... 6
Cover Letter ....................................................................................................... 7
Register to Job Portals ....................................................................................... 7
Importance of Certification.................................................................................... 7
The Interview Questions ........................................................................................ 8
Beginner ............................................................................................................. 8
Version and features ...................................................................................... 8
Some features explained ............................................................................... 9
Java in General ................................................ Error! Bookmark not defined.
OOPs................................................................ Error! Bookmark not defined.
Java language .................................................. Error! Bookmark not defined.
Moderate ............................................................ Error! Bookmark not defined.
Oops Questions ............................................... Error! Bookmark not defined.
Java language .................................................. Error! Bookmark not defined.
Collections ....................................................... Error! Bookmark not defined.
Exception Handling ......................................... Error! Bookmark not defined.
Advanced ............................................................ Error! Bookmark not defined.
4|Page Java Interview Guide - Cracked

Java language .................................................. Error! Bookmark not defined.


Equals and HashCode ...................................... Error! Bookmark not defined.
Immutable ....................................................... Error! Bookmark not defined.
Classloader ...................................................... Error! Bookmark not defined.
Collections ....................................................... Error! Bookmark not defined.
Exception Handling ......................................... Error! Bookmark not defined.
Multithreading ................................................ Error! Bookmark not defined.
Design Patterns ............................................... Error! Bookmark not defined.
More questions/concepts ............................... Error! Bookmark not defined.
Servlets................................................................ Error! Bookmark not defined.
JSP ....................................................................... Error! Bookmark not defined.
Struts ................................................................... Error! Bookmark not defined.
EJBs ..................................................................... Error! Bookmark not defined.
Spring .................................................................. Error! Bookmark not defined.
Hibernate ............................................................ Error! Bookmark not defined.
Web Services ....................................................... Error! Bookmark not defined.
Practice Questions .................................................. Error! Bookmark not defined.
Question 1 ........................................................... Error! Bookmark not defined.
Question 2 ........................................................... Error! Bookmark not defined.
Question 3 ........................................................... Error! Bookmark not defined.
Question 4 ........................................................... Error! Bookmark not defined.
Question 5 ........................................................... Error! Bookmark not defined.
Question 6 ........................................................... Error! Bookmark not defined.
Question 7 ........................................................... Error! Bookmark not defined.
5|Page Java Interview Guide - Cracked

Question 8 ........................................................... Error! Bookmark not defined.


Question 9 ........................................................... Error! Bookmark not defined.
Question 10 ......................................................... Error! Bookmark not defined.
Question 11 ......................................................... Error! Bookmark not defined.
Question 12 ......................................................... Error! Bookmark not defined.
Question 13 ......................................................... Error! Bookmark not defined.
Question 14 ......................................................... Error! Bookmark not defined.
Question 15 ......................................................... Error! Bookmark not defined.
Question 16 ......................................................... Error! Bookmark not defined.
Tools, Methodologies and Processes ...................... Error! Bookmark not defined.
Questions on soft skills ........................................... Error! Bookmark not defined.
Where to go from here? ......................................... Error! Bookmark not defined.
References: ............................................................. Error! Bookmark not defined.
6|Page Java Interview Guide - Cracked

Preparation
Choosing a resume template
If you are really serious about your new job search you must prepare your
resume to be eye-catching. It should be clear and informative with all the
information that can land you a job. To start with, you can search for some of the
resume formats online and chose one that best fits with your needs. I googled for
‘resume format doc’ and it gave me 7,43,000 results. While many sites will give
you sample resume formats for free; if you have money you can actually pay some
and get this done.

Bare minimum, a resume would include following components

 contact information
 Summary/Objective
 Educational details
 Skills and experience
 Accomplishments like awards and certifications
 Hobbies (optional)
 Personal Info including passport and work permit details

Size of resume
Many people ask me, what should be the size of my resume. While there
are no hard and fast rules to what it can and can not have, anything between2-3
pages should look good. Your resume should contain information that can get you
an invite so it should not be too short that the seeker does not find it interesting
and at the same time it should not be too descriptive that it becomes hard to
search for information that is really required.
7|Page Java Interview Guide - Cracked

Cover Letter
Cover letters are not mandatory on many occasions; however they are
good when communicating through postal mails. Try to keep a format of cover
letter ready always.

Register to Job Portals


A really job seeker would register to multiple to many localized job
portals and have his resume uploaded there. Do not just upload once and forget,
keep updating/uploading it (though it is same) once in every week.

Importance of Certification
Yes. Certifications are important. They have their own advantages so
don’t ignore them, employers don’t ignore too. You can search for what are
different certification path available from Oracle. Based on your experience you
can keep yourself updated with matching certificate, they look good on resume
and also when you are preparing for them they make you technically strong in
those areas.
8|Page Java Interview Guide - Cracked

The Interview Questions

Beginner
Version and features

What is the latest JDK version you are on?

The idea behind this question is to know if you are with latest technology
changes. I normally chose to answer it this way, "our production systems are on
JDK version XX, while in development we are at JDK version YY". Usually XX would
be a lower version compared to YY.

What are the features of JDK version 5?

 Enhanced for loop


 Autoboxing/Unboxing
 Typesafe enums
 Varargs
 Generics
 Static imports

What are the features of JDK version 6?

 Common Annotations (JSR 250)


 JAXB 2.0 (JSR 222)
 Streaming API for XML (JSR 173)
 XML Digital Signature (JSR 105)
 Java Compiler API (JSR 199)
9|Page Java Interview Guide - Cracked

What are the features of JDK version 7?

 Strings in switch statement


 Multiple catch into one (Exception handling)
 Automatic resource management (ARM)
 Diamond operator
 Fork/Join framework

What are the features of JDK version 8?

 Lambda expressions
 Stream API
 Functional interfaces
 new Date/Time API

Some features explained

Enhanced for loop:

The enhanced for loop was introduced in java 1.5.

As per Java Language Specification (JLS), the enhanced for statement has the
form:

for ( FormalParameter : Expression ) Statement

The type of the Expression must be Iterable or an array type, or a compile-time


error occurs.

Let us see how we can use this statement for array type.
10 | P a g e Java Interview Guide - Cracked

package com.org.akhil.main;

public class MainArray {

public static void main(String args[]){


String strArray[] = {"name1", "name2", "name3"};

for(String s : strArray){
System.out.println(s);
}
}

Drawback of this is that inside the loop we cannot access the index of current
iteration.

The second case is use enhanced for loop for “Iterable” type.

When we look at the Java Docs API, we see that java.util.List has super-interface
as “Iterable” so we can use our enhanced for loop to iterate over a list as below.

package com.org.akhil.main;

import java.util.ArrayList;
import java.util.List;

public class MainList {

public static void main(String args[]){

List<String> list = new ArrayList<String>();


list.add("name1");
list.add("name2");
list.add("name3");
for(String s : list){
11 | P a g e Java Interview Guide - Cracked

System.out.println(s);
}
}
}

Now let us look how we can iterate over our own class.

package com.org.akhil.main;

import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;

public class MainIterable implements Iterable<String>{

Set<String> set = new HashSet<String>();

@Override
public Iterator<String> iterator() {

return set.iterator();
}

public void add(String s){


set.add(s);
}

public static void main(String args[]){


MainIterable obj = new MainIterable();
obj.add("name1");
obj.add("name2");
obj.add("name3");

for(String s : obj){
System.out.println(s);
}
}
}
12 | P a g e Java Interview Guide - Cracked

Note how our class implements the “Iterable” interface.

AutoBoxing and Unboxing:

To understand autoboxing and unboxing better, we must know wrapper


classes. For every primitive type in java we have corresponding reference/object
types called wrapper classes. These classes are in java.lang package.
Following table shows primitive type and their corresponding wrapper class.

Primitive type Wrapper class

boolean Boolean
byte Byte
char Character
float Float
int Integer
long Long
short Short
double Double

There are times when Java compiler automatically converts from primitive type
to corresponding wrapper type and vice-versa. The conversion from primitive to
wrapper is called autoboxing and conversion from wrapper to primitive type is
known as unboxing.

So when does the compiler decide to do such conversions? As per java tutorial,
these conversions happen in two cases…

 When Passed as a parameter to a method that accepts


primitive/wrapper
 When assigned to a variable of primitive/wrapper type

Let us see the first case where method parameters are automatically gets
autoboxed:
13 | P a g e Java Interview Guide - Cracked

package com.org.akhil.Boxing;

public class MainAutoBoxing {


public static void main(String args[]){
passObject(3);
}
public static void passObject(Integer i){
System.out.println(i);
}

The above will print 3.

The following DOES NOT work

package com.org.akhil.Boxing;

public class MainAutoBoxing {


public static void main(String args[]){
passObject(3);
}
public static void passObject(Double i){
System.out.println(i);
}

Compiler Error : The method passObject(Double) in the type MainAutoBoxing is not


applicable for the arguments (int)
14 | P a g e Java Interview Guide - Cracked

The following DOES NOT work

package com.org.akhil.Boxing;

public class MainAutoBoxing {


public static void main(String args[]){
passObject(3.0);
}
public static void passObject(Integer i){
System.out.println(i);
}

Compiler Error: The method passObject(Integer) in the type MainAutoBoxing is not


applicable for the arguments (double)

For the case on unboxing let us see below example:

package com.org.akhil.Boxing;

public class MainUnboxing {


public static void main(String args[]){
passObject(new Integer(3));
}
public static void passObject(int i){
System.out.println(i);
}

}
15 | P a g e Java Interview Guide - Cracked

This is a FREE Sample.

Purchase Full ebook at

https://leanpub.com/javainterviewguide-cracked

You might also like