JUnit (Java Unit Testing) interview questions

by Chaitanya Singh May 21, 2013

Question1: What is Junit? Answer: Java + unit testing = Junit Junit is open source testing framework developed for unit testing java code and is now the default framework for testing Java development. It has been developed by Erich Gamma and Kent Beck. It is an application programming interface for developing test cases in java which is part of the XUnit Family. It helps the developer to write and execute repeatable automated tests. Eclipse IDE comes with both Junit and

Read the full article →

JDBC(Java Database Connectivity) interview questions

by Chaitanya Singh May 21, 2013

Q) What is JDBC (Java Database Connectivity)? JDBC is Java Database Connectivity. It allows you to have a single API for connecting to, manipulating, and retrieving information from a multiple Databases like MySQL, Oracle, DB2, etc. Q) What is JDBC Driver ?  JDBC driver is used to established a connection with the database so that you can fetch, update and maintain database tables using SQL queries, once the connection is made using these drivers. Q) What are the differences between the 4 types of

Read the full article →

Servlet interview questions

by Chaitanya Singh May 20, 2013

Q) Peformance wise which one is better JSP page or servlet? you can say that JSP and servlet performance is almost same. However when JSP page is accessed very first time, it takes more time compared to servlet as it goes into a translation phase, wherein JSP engine converts it into a servlet. Once this servlet(converted from JSP) is compiled and loaded into memory, it follows the servlet life cycle for each request. Hence JSP and servlet performance is same

Read the full article →

Flow control in try-catch-finally blocks

by Chaitanya Singh May 19, 2013

First I will show you control flow in try/catch block after that we will see flow in try-catch-finally blocks. Flow of control in try/catch blocks: when exception doesn’t occur: When code inside try block doesn’t throw any exception then first body of try block executes and then the code after catch blocks. In this case catch block never runs. for example- Output: next-statement: Inside try block next-statement: Outside of try-catch In the above example exception didn’t occur in try block, hence

Read the full article →

Java Tutorial 4 – Java Arrays

by Chaitanya Singh May 18, 2013

What are Arrays in Java? Arrays are objects which store multiple variables of the same type. It can hold primitive types as well as object references. In fact most of the collection types in Java which are the part of java.util package use arrays internally in their functioning. Since Arrays are objects, they are created during runtime .The array length is fixed. Features of Array Arrays are objects They can even hold the reference variables of other objects They are

Read the full article →

Java Tutorial

by Chaitanya Singh May 18, 2013

I have written 100+ tutorials in Java. Here I have consolidated and made a list of java tutorials through which even a beginner can learn java easily. If you are a beginner then follow below articles in the given sequence and if you’re looking for a specific java area then choose the article from the below list. Basics of Java – Tutorials Introduction to Java JVM – Java virtual machine First program in Java Java Arrays Static in Java: Java static

Read the full article →

Java Tutorial 3- Compilation and Execution of First Java Program

by Chaitanya Singh May 18, 2013

To create a java code an editor such as notepad, text pad or an IDE like eclipse can be used. Sample Java Code: Output: This is my first program in java In the above program the class FirstJavaProgram has public access and hence declared public. ‘class’ is the keyword used to create a class. For running stand-alone programs ‘main’ method is needed which has a signature similar to the one defined in the above program. ‘Main’ method takes an array

Read the full article →

Java Tutorial 2 – JVM (Java virtual Machine)

by Chaitanya Singh May 18, 2013

1)      Class loader accepts class files 2)      Compilation creates class files 3)      The interim memory is required during execution 4)      It consists of heaps, stacks and registers to store data 5)      JRE has native methods and libraries 6)      JVM runs two main threads a)      demon b)      Non-demon threads Demon Threads It has been Run by JVM for itself. Used for garbage collection. JVM decides on a thread for being a demon thread Non-demon threads main() is the initial and non-demon

Read the full article →

Java Tutorial 1 – Introduction

by Chaitanya Singh May 18, 2013

Introduction JAVA was originated at Sun Microsystems Inc., in 1991. It was conceived by James Gosling and Patrick Naughton. Simple programming language to write, compile and debug a program easily.  It helps to create modular programs and reusable code. Main Features of JAVA Java is a platform independent An application developed on Java can run in any machine. When Java is compiled, it is not compiled into platform specific machine or platform independent byte code. The byte code is distributed

Read the full article →

Java interview questions

by Chaitanya Singh May 16, 2013

Java – OOPs Interview questions Q) Three Principles of OOPS language? Inheritance Polymorphism Data Encapsulation Q) Java vs. C ++? Simple Multi-threaded Distributed Application Robust Security Complexities are removed (Pointers, Operator overloading, Multiple inheritance). Q) What is javac ? It produces the java byte code when *.java is given as input and it is the intermediate representation of your source code that contains instructions that the java interpreter will execute. Q) What all terms are related to OOPs? Class Object

Read the full article →

Hadoop Distributed File System(HDFS)

by Chaitanya Singh May 13, 2013

Before understanding what is HDFS first I would like to explain what is distributed file system. What is Distributed File System? As you know that each physical system has its own storage limit. And when it comes to store lots of data then we may need more than one system, Basically a network of systems. So that the data can be segregated among various machines which are connected to each other through a network. Such type of management in order to store bulk of data

Read the full article →

Hadoop tutorial

by Chaitanya Singh May 13, 2013

1. History of Hadoop Hadoop was created by Goug Cutting, he is the creator of Apache Lucene, the widely used text search library. Hadoop has been originated from Apache Nutch, which is an open source web search engine. 1.1. Origin of Name Hadoop Hadoop doesn’t have a meaning, neither its a acronym. The project creator Doug Cutting explains how they named it as Hadoop – This name is given by my Kid to his yellow stuffed elephant. It’s short, easy

Read the full article →

How to Catch multiple exceptions

by Chaitanya Singh May 13, 2013

A method can throw more than one exceptions. However that method needs to declare all the checked exceptions it can throw (optionally method can declare the super class of exception if it is common among all the exceptions). Catching multiple exceptions lets have a look at the below example to understand it better: Example1 Exceptions are polymorphic in nature Now I’m going to rewrite the above example in different form: Example2 By using only one catch block I have handled

Read the full article →

Interface in java

by Chaitanya Singh May 13, 2013

An interface in java is an abstract type which is used to specify an interface (generic sense) that java class will implement. Declaration Interfaces are created by specifying a keyword “interface”. E.g.: Implementation Key points: 1) While providing implementation of any interface method, it needs to be mentioned as public. 2) Class implementing any interface must implement all the methods, otherwise the class should be declared as “abstract”. 3) Interface cannot be declared as private, protected or transient. 4) All

Read the full article →

Abstract Classes and Methods in Java

by Chaitanya Singh May 12, 2013

A class which can not be instantiated is known as abstract class. In other words – you are not allowed to create object of Abstract class. Abstract class declaration Putting abstract keyword before class declaration makes it abstract. Have a look at below code: Error!! – Object creation of abstract class not allowed Why we need an abstract class? Let me explain this with an example. Suppose there is a class Animal. Also, there are few classes like Cat, Dog &

Read the full article →