FullStack.
Cafe - Kill Your Tech Interview
FullStack.Cafe - Kill Your Tech Interview
Q1: What is JVM? Why is Java called the "Platform Independent
Programming Language”? ☆
Topics: Java
Answer:
A Java virtual machine (JVM) is a process virtual machine that can execute Java bytecode. Each Java source file is
compiled into a bytecode file, which is executed by the JVM. Java was designed to allow application programs to
be built that could be run on any platform, without having to be rewritten or recompiled by the programmer for
each separate platform. A Java virtual machine makes this possible, because it is aware of the specific instruction
lengths and other particularities of the underlying hardware platform.
Q2: What is the Difference between JDK and JRE? ☆
Topics: Java
Answer:
**The Java Runtime Environment (JRE) **is basically the Java Virtual Machine (JVM) where your Java
programs are being executed. It also includes browser plugins for applet execution.
The Java Development Kit (JDK) is the full featured Software Development Kit for Java, including the JRE,
the compilers and tools (like JavaDoc, and Java Debugger), in order for a user to develop, compile and
execute Java applications.
Q3: What are the two types of Exceptions in Java? Which are the
differences between them? ☆
Topics: Java
Answer:
Java has two types of exceptions: checked exceptions and unchecked exceptions.
1. **Unchecked exceptions **do not need to be declared in a method or a constructor’s throws clause, if they
can be thrown by the execution of the method or the constructor, and propagate outside the method or
constructor boundary.
2. On the other hand, checked exceptions must be declared in a method or a constructor’s throws clause.
Q4: What is the difference between an Applet and a Java
Application? ☆
Topics: Java
Answer:
Page 1 of 5
FullStack.Cafe - Kill Your Tech Interview
Applets are executed within a Java enabled browser, but a
Java application is a standalone Java program that can be executed outside of a browser.
However, they both require the existence of a Java Virtual Machine (JVM). Furthermore, a Java application
requires a main method with a specific signature, in order to start its execution. Java applets don’t need such a
method to start their execution. Finally, Java applets typically use a restrictive security policy, while Java
applications usually use more relaxed security policies.
Q5: What is a JSP Page? ☆
Topics: Java
Answer:
A Java Server Page (JSP) is a text document that contains two types of text:
static data and
JSP elements.
Static data can be expressed in any text-based format, such as HTML or XML. JSP is a technology that mixes
static content with dynamically-generated content.
Q6: What is a Servlet? ☆
Topics: Java
Answer:
The servlet is a Java programming language class used to process client requests and generate dynamic web
content. Servlets are mostly used to process or store data submitted by an HTML form, provide dynamic content
and manage state information that does not exist in the stateless HTTP protocol.
Q7: What does the static keyword mean? Can you override
private or static method in Java? ☆☆
Topics: Java
Answer:
The static keyword denotes that a member variable or method can be accessed, without requiring an
instantiation of the class to which it belongs.
A user cannot override static methods in Java, because method overriding is based upon dynamic binding at
runtime and static methods are statically binded at compile time. A static method is not associated with any
instance of a class so the concept is not applicable.
Q8: What are the Data Types supported by Java? What is
Autoboxing and Unboxing? ☆☆
Topics: Java
Answer:
Page 2 of 5
FullStack.Cafe - Kill Your Tech Interview
The eight primitive data types supported by the Java programming language are:
byte
short
int
long
float
double
boolean
char
Autoboxing is the automatic conversion made by the Java compiler between the primitive types and their
corresponding object wrapper classes. If the conversion goes the other way, this operation is called unboxing.
Q9: What are pass by reference and pass by value? ☆☆
Topics: Java
Answer:
When an object is passed by value, this means that a copy of the object is passed. Thus, even if changes
are made to that object, it doesn’t affect the original value.
When an object is passed by reference, this means that the actual object is not passed, rather a reference
of the object is passed. Thus, any changes made by the external method, are also reflected in all places.
Q10: What is the difference between processes and threads? ☆☆
Topics: Java
Answer:
The main difference between them is that
a Process is a program which is executing some code and
a Thread is an independent path of execution in the process.
A process can have more than one thread for doing independent task e.g. a thread for reading data from disk, a
thread for processing that data and another thread for sending that data over the network.
Q11: What are the basic interfaces of Java Collections Framework?
☆☆
Topics: Java
Answer:
Java Collections Framework provides a well designed set of interfaces and classes that support operations on
a collections of objects. The most basic interfaces that reside in the Java Collections Framework are:
Collection, which represents a group of objects known as its elements.
Set, which is a collection that cannot contain duplicate elements.
List, which is an ordered collection and can contain duplicate elements.
Map, which is an object that maps keys to values and cannot contain duplicate keys.
Page 3 of 5
FullStack.Cafe - Kill Your Tech Interview
Q12: What is an Iterator? ☆☆
Topics: Java
Answer:
The Iterator interface provides a number of methods that are able to iterate over any Collection. Each Java
Collection contains the Iterator method that returns an Iterator instance. Iterators are capable of removing
elements from the underlying collection during the iteration.
Q13: How HashMap works in Java? ☆☆
Topics: Java
Answer:
A HashMap in Java stores key-value pairs. The HashMap requires a hash function and uses hashCode and equals
methods, in order to put and retrieve elements to and from the collection respectively. When the put method is
invoked, the HashMap calculates the hash value of the key and stores the pair in the appropriate index inside the
collection. If the key exists, its value is updated with the new value. Some important characteristics of a
HashMap are its capacity, its load factor and the threshold resizing.
Q14: What differences exist between HashMap and Hashtable ? ☆☆
Topics: Java
Answer:
There are several differences between HashMap and Hashtable in Java:
1. Hashtable is synchronized, whereas HashMap is not. This makes HashMap better for non-threaded
applications, as unsynchronized Objects typically perform better than synchronized ones.
2. Hashtable does not allow null keys or values. HashMap allows one null key and any number of null
values.
3. One of HashMap's subclasses is LinkedHashMap , so in the event that you'd want predictable iteration order
(which is insertion order by default), you could easily swap out the HashMap for a LinkedHashMap . This
wouldn't be as easy if you were using Hashtable .
Q15: What is the purpose of Garbage Collection in Java, and when
is it used? ☆☆
Topics: Java
Answer:
The purpose of garbage collection is to identify and discard those objects that are no longer needed by the
application, in order for the resources to be reclaimed and reused.
Q16: What does System.gc() and Runtime.gc() methods do? ☆☆
Topics: Java
Page 4 of 5
FullStack.Cafe - Kill Your Tech Interview
Answer:
These methods can be used as a hint to the JVM, in order to start a garbage collection. However, this it is up to
the Java Virtual Machine (JVM) to start the garbage collection immediately or later in time.
Q17: When does an Object becomes eligible for Garbage Collection
in Java ? ☆☆
Topics: Java
Answer:
A Java object is subject to garbage collection when it becomes unreachable to the program in which it is currently
used.
Q18: What is the difference between Exception and Error in Java?
☆☆
Topics: Java
Answer:
An Error "indicates serious problems that a reasonable application should not try to catch."
An Exception "indicates conditions that a reasonable application might want to catch."
Q19: What is the importance of finally block in exception
handling? ☆☆
Topics: Java
Answer:
A finally block will always be executed, whether or not an exception is actually thrown. Even in the case where
the catch statement is missing and an exception is thrown, the finally block will still be executed. Last thing to
mention is that the finally block is used to release resources like I/O buffers, database connections, etc.
Q20: What is an Java Applet? ☆☆
Topics: Java
Answer:
A Java Applet is program that can be included in a HTML page and be executed in a java enabled client browser.
Applets are used for creating dynamic and interactive web applications.
Page 5 of 5