Interview

Most frequently asking java basics interview questions and answers has been updated in the post. 
Q1: How many JVM's can run on a single machine?

A:
No limitation. JVM is just like any other process.

Q2: 
What is the Just-In-Time (JIT) compiler?

A:
The java interpreter on any platform will interpret the compiled bytecode into instructions understandable by the particular hardware. However, the Java Virtual Machine handles one bytecode instruction at a time. The Just-In-Time compiler compiles the bytecode into the particular machine code. Once the code has been (re-)compiled by the JIT compiler, it will usually run more quickly in that system.
(OR)
JIT Compiler is the part of JVM which increases the speed of execution of a java program.

Q3: 
What is the use of 'classpath' environment variable?

A:
Classpath is the list of directories through which the jvm will search to find a class. It is different from OS environment variable PATH.

If you need to learn how to set classpath, please go through this link set Java Path?

Q4:
 Can java code be retrieved from byte-code?

A:
Yes, class files can be de-compiled using utilities like JAD. This takes the class file as input and generates a java file.

Q5: 
What is a garbage collection?

A:
When an object is no longer required (when its reference count is 0), its memory needs to be cleaned up and freed. This is what the garbage collector does. Garbage collector is a thread running as part of the JVM process. The basic garbage collector uses "mark and sweep" algorithm.

Q6: 
Can the garbage collector be forced to run?

A: No. Calling the System.gc() method only suggest that the JVM expand effort toward recycling unused objects in order to make the memory they currently occupy available for them. When control returns from the method call, the JVM has made a best effort to reclaim space from all declared objects. This doesn't guarantee that the garbage collector is called

The call System.gc() is effectively equivalent to the call:

Runtime.getRuntime().gc()


(Or)
Garbage Collector is automatically invoked when the program is being run. It can be also called by calling gc() method of Runtime class or System class in java.
  • Java Basics

JDBC:

JSP:
Google Interview Questions:
  • What is promising and Hoisting in JavaScript?
  • How will you make async call from JavaScript?
  • What is box model in CSS?
  • What is the major differences between ArrayList and LinkedList?
  • How will you prove LinkedList is better than ArrayList to store elements in the middle?
  • What are the differences between HashMap, TreeMap and LinkedHashMap?
  • Write a method to get an element from given array by using BinarySearch?
    • int[] ar = {4,1,3,10,-4,-2};
  • What are the different approaches of Sorting the above Array?
  • What are the different types of design patterns you worked?
  • What is the best way of implementing Singleton design pattern?
  • What is the difference between Factory and Abstract Factory pattern?
  • How will you implement Builder patter?

Popular posts from this blog

Hibernate auto increment with example

how to count the page views by using JSP

Multithreading in java with example

How to retrieve data from table by using JDBC with example

Prime, Fibonacci and Factorial number with example in java

How to insert images into database using JDBC?

How to sort list of objects in java with examples

String interview questions and answers

Exception in thread "main" java.lang.NoClassDefFoundError: javax/transaction/SystemException

Store file into table by using JDBC with example