Skip to main content

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

JVM, JRE and JDK in Java

JVM, JRE and JDK are the most basic common concepts to know in java. These are the basic features to understand how Java architecture works? JVM stands for Java Virtual Machine, which doesn't have any physical directories created in java installation. JRE stands for Java Runtime Environment, which creates the directory under Java installation path and also present in JDK. JDK stands for Java Development Kit, which creates the directory in Java installation path and also it has it's own JRE. Since we have already learn that Java is platform independent means if we have implemented any of the java class in one environment, it will be executed in any other environment and provides the same output. But, JVM, JRE and JDK all are platform dependent . So that, for windows, linux, unix, mac, solaris..etc has it's own JVM, JRE and JDK. One will be not compatible with other environments. While installing the Java, we might come to know a bit about JRE and JDK. But, JVM is the other...

Prime, Fibonacci and Factorial number with example in java

Prime number, Fibonacci series and Factorial number programs are most commonly asked questions in interview. Read this article to know what is and how to write programs for prime number, fibonacci series and factorial number. Prime Number: prime number is natural number greater than 1 that has no positive divisor other than 1 and itself. A natural number greater than 1 is not a prime number, is called Composite number . For example, 7 is a prime number. Because it can divide with 1 and 7 only. Where as 8 is composite number. Since it has the divisor 2 and 4 in addition to the 1 and 8. The below example represents the finding the passing number is prime number or not. If the passing number is prime number it will print true otherwise it will print false. package com . javatbrains . practice ; public class PrimeNumber { public boolean isPrimeNumber ( int number ) { if ( number <= 1 ) return false ; // There's only one ...

How to insert images into database using JDBC?

How to insert images into database table by using JDBC? To know about these topic follow the below lines,           Before going to write a JDBC program for inserting images into database table, we need to create a specific table for inserting images column datatype. For creating the database table, execute the below command in MySQL command prompt. 1 2 3 4 CREATE TABLE ` images ` ( ` image_id ` int ( 11 ) NOT NULL AUTO_INCREMENT, ` image_flag ` int ( 11 ) NOT NULL , ` image ` longblob NOT NULL , PRIMARY KEY ( ` image_id ` ));           After executing the above query in MySQL command prompt, execute the below query to know weather the above table query is created or not. 1 Show tables;            When you have executed the above query that will show you the list of table which all exists in the current database. Current tab...