CORE JAVA INTERVIEW. QUESTIONS AND ANSWERS. Table of Contents. 1) what are static blocks and static initalizers in Java?. Interview Questions in Core Java. is a Which classes and interfaces support event handling? Following answer may not be correct. We assure that you will get here the 90% frequently asked interview questions and answers. The answers to the core java interview questions are short and to.

Core Java Interview Questions And Answers Pdf

Language:English, German, Hindi
Genre:Fiction & Literature
Published (Last):07.07.2016
ePub File Size:15.78 MB
PDF File Size:13.48 MB
Distribution:Free* [*Sign up for free]
Uploaded by: CLARIS

Dear readers, these Java Interview Questions have been designed especially during your interview, normally questions start with some basic concept of the subject and later they continue based on further discussion and what you answer −. Basic Java Interview Questions and Answers for Freshers or Experienced Pdf. This interview section questions contains a brief introduction to the Java. java interview questions and answers PDF, java interview questions PDF eBook Free download, core java interview questions pdf, + questions, 60+ pages.

It is a much lighter and readable alternative to XML. Easy to parse and conversion to objects for information consumption. Name the methods of Object Class? Read this tutorial to learn more about Java Methods. Define content negotiation? If we have visited website to searching the information, we will get the information in different languages and in different formats when a client makes an HTTP request to a server, the client can also specify the media types here.

The client can specify what it can accept back from the host and on the basis of availability the host will return to the client. This is known as content negotiation because client and server negotiated on the language and format of the content to be shared. Will the JVM load the package twice at runtime? A package or class can be inherited multiple times in a program code. JVM and compiler will not create any issue. Moreover JVM automatically loads the class internally once regardless of times it is called in the program.

Don't Miss These Goodies

Define Abstract class? A class which contains the abstract keyword in its declaration is known as abstract class. It can have abstract and non-abstract methods method with body. This class can have public, private, protected or constants and default variables.

It needs to be extended and its method implemented. It cannot be instantiated. If a class has at least one abstract method, then the class must be declared abstract. Describe the Annotations. Java Annotations is a tag which symbolizes metadata associated with class, interface, methods, fields, etc. Annotations do not directly influence the operations.

The additional information carried by annotations are utilized by java compiler and JVM. Java doesn't use pointers. Pointers are susceptible and slight carelessness in their use may result in memory problems and hence Java basically manages their use. Distinguish between static loading and dynamic class loading? Dynamic class loading — It is a technique for programmatically invoking the functions of a class loader at run time.

The syntax isClass. Struts 1 actions are a singleton.

Top 53 Core Java Basic Interview Questions And Answers Pdf

So all threads operate on the single action object and hence make it thread-unsafe. Struts 2 actions are not a singleton and a new action object copy are created each time a new action request is made and hence it threads safe. Define an enumeration? Usually, we called enumeration as an enum. An enumeration is an interface containing methods for accessing the original data structure from which the enumeration is obtained. It allows sequential access to all the elements stored in the collection.

How can we find the actual size of an object on the heap? In Java, there is no way to find out the actual size of an object on the heap.

Which API is provided by Java for operations on a set of objects? Java provides a Collection API which provides many useful methods which can be applied to a set of objects. Why we used Vector class? The Vector class provides the ability to execute a growable array of objects. What is the difference between transient and volatile variable in Java? Transient: In Java, it is used to specify the variable is not being serialized.

So, declare those variables as transient. If the variable is confirmed as transient, then it will not be persisted. Transient keyword is used with that instance variable which will not participate in the serialization process.

We cannot use static with a transient variable as they are part of the instance variable. The map interface is not compatible with the Collection interface. Because Map requires key as well as value, for example: if we want to add key-value pair so we will use put Object key , Object value. There are two parameters required to add an element to HashMap object.

In Collection interface add Object o has only one parameter. The other reasons are Map supports valueSet, keySet as well as other suitable methods which have just different views from the Collection interface. Mention the uses of Synchronized block We are using Synchronized block because It helps to lock an object for every shared resource. The scope of synchronized block is smaller than the method. What are the functions of hashCode method?

This method returns a hash code value an integer number. And also returns the same integer number, if two keys by calling equals method are same. But in sometimes two hash code numbers can have different or same keys. What is the default size of load factor in hashing based collection? Custom tags can manipulate JSP content, but beans cannot. Composite operations can be reduced to a considerably simpler form with custom tags than with beans. Custom tags require reasonably a bit more work to set up than do beans.

Custom tags are available only in JSP 1. The expression language is used in JSP to simplify the accessibility of objects and It provides many objects that can be used directly like param, requestScope, sessionScope, applicationScope, request, session etc. What are implicit objects? Implicit objects, also called as pre-defined variables, are created by JSP Engine inside the service method so that it can be accessed directly without being declared explicitly.

Define a cookie and what are the difference between session and cookie? A cookie is a small piece of information, this piece of information sends to the browser by a web server.

The browser stores the cookies for every Web server in a local file. In a future request or future reference, the browser sends all stored cookies for that detailed Web server.

The difference between cookies and sessions are: The session is working, regardless of the settings on the client browser. For more details, please check our java class tutorial. The allowed modifiers for a class are nothing or the public modifier. When declaring an attribute in a class without specifying its visibility, it has the default visibility. The default visibility is the package visibility. This keyword contains a reference to the current class. A constructor is a method that initializes the attributes of an object when it is created.

The constructor is called when using the new keyword. The default constructor is the constructor that has no arguments. When overloading constructor, the compiler will not auto-generate the default constructor for us.

Top 53 Core Java Basic Interview Questions And Answers Pdf

So, we should write the default constructor by ourselves. This can cause many problems when using the well known frameworks like hibernate, spring, etc 21 Do child classes inherit the constructor of parent classes?

No, the constructor is not inherited. We can call the constructor of the parent class explicitly using the super keyword. Yes, a constructor can be overloaded. No, overriding concept is related to inheritance. The constructor is not inherited.

No, a constructor cannot be final. For more details, please check our java constructor tutorial. We cannot make child classes from this class. We cannot inherit from a final class. The method cannot be overridden. The variable is constant. We cannot change its value once it is initialized. This is a variable declared as final and not initialized when declaring it.

The blank final variable should be initialized in the constructor of the class if it is not static. If it is static, we should initialize it in a static block. For more details, please check our java variables for beginners tutorial. Yes It is a class that has the abstract keyword in its declaration. This class cannot be instantiated. It is created to be inherited.

A class that has at least one abstract method is an abstract class. It is a method that has no implementation and is marked with the abstract keyword. Method overriding is used when creating a method that is provided in the parent class in a child class.

This concept is tightly related to inheritance. Yes, there is no problem. For more details, please check our java method overriding tutorial. Method overriding is used inside a single class.

It is used when creating, in the same class, many methods that have the same name but differ by the list of arguments.

No, keeping the same list of parameters and changing only the return type will cause a compiler error. Yes For more details, please check our java method overloading tutorial. They are related to the polymorphism concept. In JAVA, all the methods are virtuals. Method Overloading Method Overriding In the child classes: related to inheritance Different parameters list 42 What is inheritance?

A class B inherits from class A. The class B inherits some attributes and method from the class A under certain conditions public and protected members are inherited.

In this case, class A is called the parent class super class and class B is called the child class. The inheritance allows the reuse of the code of the parent class inside child classes.

The Object class. The super keyword is used inside the child class to call a method present in the parent class explicitly using the dot notation.

You might also like: RIO FERDINAND BOOK

We can call a constructor present in the parent class using the super keyword. No, because each one among the two calls needs to be the first statement. No The use of interfaces For more details, please check our java inheritance tutorial. Abstract class abstract classes has abstract methods and implemented methods. So, the child class needs only to implement the abstract interface The implementing class must implement all the methods of the interface or it will be methods to be non abstract.

The interface can only have final data.Constructor chaining enables us to call one constructor from another constructor of the class with respect to the current class object. Static variable belongs to the class rather than the object. Which java. No, we can't override static methods.

Yes, the constructors can be overloaded by changing the number of arguments accepted by the constructor or by changing the data type of the parameters.

Check this post to learn how to compile and run java program.

STEFAN from Newport News
Feel free to read my other posts. I am highly influenced by gardening. I relish deeply .