Java Basic interview questions and answer

  • What is garbage collection? What is the process that is responsible for doing that in java? - Reclaiming the unused memory by the invalid objects. Garbage collector is responsible for this process

  • What kind of thread is the Garbage collector thread? - It is a daemon thread.
  • What is a daemon thread? - These are the threads which can run without user intervention. The JVM can exit when there are daemon thread by

Java Most asked question for fresher and experience



What is an abstract method?

An abstract method is a method which doesn’t have a body, just declared with modifier abstract.

Explain the use of the finally block.

Finally block is a block which always executes. The block executes even when an exception is occurred. The block won't execute only when the user calls System.exit()

What is the initial state of a thread?

It is in a ready state.

What is time slicing?

In time slicing, the task continues its execution for a predefined period of time and reenters the pool of ready tasks.

Java interview questions and answers Part 2


1. What is the difference between a constructor and a method?
A constructor is a member function of a class that is used to create objects of that class. It has the same name as the class itself, has no return type, and is invoked using the new operator.
A method is an ordinary member function of a class. It has its own name, a return type (which may be void), and is invoked using the dot operator.
2. What is the purpose of garbage collection in Java, and when is it used?
The purpose of garbage collection is to identify and discard objects that are no longer needed by a program so that their resources can be reclaimed and reused.
A Java object is subject to garbage collection when it becomes unreachable to the program in which it is used.

Java interview questions and answers Part 1


1. What is the most important feature of Java?
Java is a platform independent language.
2. What do you mean by platform independence?
Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc).
3. What is a JVM?
JVM is Java Virtual Machine which is a run time environment for the compiled java class files.
4. Are JVM's platform independent?
JVM's are not platform independent. JVM's are platform specific run time implementation provided by the vendor.

PHP interview questions and answer for fresher and experience



1) What is PHP?
PHP is a web language based on scripts that allows developers to dynamically create generated web pages.
2) What does the initials of PHP stand for?
PHP means PHP: Hypertext Preprocessor.
3) Which programming language does PHP resemble to?
PHP syntax resembles Perl and C