Core Java Study guide and interview questions - Part 4

This is the 4th part of the 500+ Core JAVA interview questions and answers. These questions can also be used as a quick study guide for preparing for an interview or for any Core JAVA concepts revision. These questions cover all the topics in core JAVA from basics to advanced concepts. 

51.What is a native method?
 A native method is a method that is implemented in a language other than Jav

52.What is the catch or declare rule for method declarations?
 If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause.

53.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

54.What kind of thread is the Garbage collector thread?
 It is a daemon thread.

55.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 killing them abruptly.

56.How will you invoke any external process in Java?

57.What is the finalize method do?
Before the invalid objects get garbage collected, the JVM give the user a chance to clean up some resources before it got garbage collected.

58.What is mutable object and immutable object?
 If a object value is changeable then we can call it as Mutable object. (Ex., StringBuffer, …) If you are not allowed to change the value of an object, it is immutable object. (Ex., String, Integer, Float, …)

59.What is the basic difference between string and stringbuffer object?
 String is an immutable object. StringBuffer is a mutable object.

60.What is the purpose of Void class?
 The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.

61.What is the purpose of Void class?
 The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the primitive Java type void.

62.What is reflection?
 Reflection allows programmatic access to information about the fields, methods and constructors of loaded classes, and the use reflected fields, methods, and constructors to operate on their underlying counterparts on objects, within security restrictions.

63.What is the base class for Error and Exception?

64.What is the byte range?
128 to 127

65.What is the implementation of destroy method in jav. is it native or java code?
This method is not implemented.

66.What is a package?
 To group set of classes into a single unit is known as packaging. Packages provides wide namespace ability.

67.What are the approaches that you will follow for making a program very efficient?
By avoiding too much of static methods avoiding the excessive and unnecessary use of synchronized methods Selection of related classes based on the application (meaning synchronized classes for multiuser and non-synchronized classes for single user) Usage of appropriate design patterns Using cache methodologies for remote invocations Avoiding creation of variables within a loop and lot more.

68.What is a DatabaseMetaData?
 Comprehensive information about the database as a whole.

69.What is Locale?
 A Locale object represents a specific geographical, political, or cultural region

70.How will you load a specific locale?
 Using ResourceBundle.getBundle(…);

71.What is JIT and its use?
 Really, just a very fast compiler… In this incarnation, pretty much a one-pass compiler — no offline computations. So you can’t look at the whole method, rank the expressions according to which ones are re-used the most, and then generate code. In theory terms, it’s an on-line problem.

72.Is JVM a compiler or an interpreter?

73.When you think about optimization, what is the best way to findout the time/memory consuming process?
Using profiler

74.What is the purpose of assert keyword used in JDK1.4.x?
 In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.

75.How will you get the platform dependent values like line separator, path separator, etc., ?
 Using Sytem.getProperty(…) (line.separator, path.separator, …)

76.What is skeleton and stub? what is the purpose of those?
Stub is a client side representation of the server, which takes care of communicating with the remote server. Skeleton is the server side representation. But that is no more in use… it is deprecated long before in JDK.

77.What is the final keyword denotes?
 final keyword denotes that it is the final implementation for that method or variable or class. You can’t override that method/variable/class any more.

78.What is the significance of ListIterator?
 You can iterate back and forth.

79.What is the major difference between LinkedList and ArrayList?
 LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.

80.What is nested class?
  If all the methods of a inner class is static then it is a nested class.

81.What is inner class?
 If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.

82.What is composition?
 Holding the reference of the other class within some other class is known as composition.

83.What is aggregation?
It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.

84.What are the methods in Object?
 clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString

85.Can you instantiate the Math class?
 You can’t instantiate the math class. All the methods in this class are static. And the constructor is not public.

86.What is singleton?
  It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods … }

87.What is DriverManager?
 The basic service to manage set of JDBC drivers.

88.What is Class.forName() does and how it is useful?
 It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( “class-instance”.newInstance() ).

90.How many types of memory areas are allocated by JVM?
Many types:
1.    Class(Method) Area
2.    Heap
3.    Stack
4.    Program Counter Register
5.    Native Method Stack

91.What is JIT compiler?
Just-In-Time(JIT) compiler:It is used to improve the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU.

92.What is platform?
A platform is basically the hardware or software environment in which a program runs. There are two types of platforms software-based and hardware-based. Java provides software-based platform.

93.If I do not provide any arguments on the command line, then the String array of Main method will be empty or null?
It is empty. But not null.

94.What is the default value of the local variables?
The local variables are not initialized to any default value, neither primitives nor object references.

95.What is classloader? 
The classloader is a subsystem of JVM that is used to load classes and interfaces.There are many types of classloaders e.g. Bootstrap classloader, Extension classloader, System classloader, Plugin classloader etc.

96.Is Empty .java file name a valid source file name?
Yes, save your java file by .java only, compile it by javac .java and run by java yourclassname Let's take a simple example:
//save by .java only

class A{
public static void main(String args[]){
System.out.println("Hello java");

//compile by javac .java
//run by     java A
compile it by javac .java
run it by java A

97.Is delete,next,main,exit or null keyword in java?

98.What is the main difference between Java platform and other platforms?
The Java platform differs from most other platforms in the sense that it's a software-based platform that runs on top of other hardware-based platforms.It has two components:
1.    Runtime Environment
2.    API(Application Programming Interface)

99.What if I write static public void instead of public static void?
Program compiles and runs properly.

100.What gives Java its 'write once and run anywhere' nature?
The bytecode. Java is compiled to be a byte code which is the intermediate language between source code and machine code. This byte code is not platorm specific and hence can be fed to any platform.

101.What is difference between object oriented programming language and object based programming language?
Object based programming languages follow all the features of OOPs except Inheritance. Examples of object based programming languages are JavaScript, VBScript etc.

102.What will be the initial value of an object reference which is defined as an instance variable?
The object references are all initialized to null in Java

Next : 1000+ core JAVA quick study material & interview Questions and Answers

What Others are Reading Now...

0 Comment to "Core Java Study guide and interview questions - Part 4"

Post a Comment