InterviewSolution
This section includes InterviewSolutions, each offering curated multiple-choice questions to sharpen your knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
How Can We Restrict Inheritance For A Class? |
|
Answer» We can RESTRICT inheritance for class by following steps. We can restrict inheritance for class by following steps. |
|
| 2. |
Why Does Map Interface Not Extend The Collection Interface In The Java Collections Framework? |
|
Answer» 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 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. |
|
| 3. |
What Is The Difference Between Transient And Volatile Variable In Java? |
|
Answer» TRANSIENT: In Java, it is used to specify the VARIABLE is not being serialized. Serialization is a process of SAVING an object’s state in Java. When we want to persist and the object’s state by default, all instance VARIABLES in the object are STORED. In some cases, if we want to avoid persisting few variables because we don’t have the necessity to transfer across the network. 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. Transient: In Java, it is used to specify the variable is not being serialized. Serialization is a process of saving an object’s state in Java. When we want to persist and the object’s state by default, all instance variables in the object are stored. In some cases, if we want to avoid persisting few variables because we don’t have the necessity to transfer across the network. 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. |
|
| 4. |
Why We Used Vector Class? |
|
Answer» The Vector CLASS provides the ability to EXECUTE a growable ARRAY of objects. Vector proves to be very useful if you don’t know the size of the array in ADVANCE, or we need one that can CHANGE sizes over the lifetime of a program. The Vector class provides the ability to execute a growable array of objects. Vector proves to be very useful if you don’t know the size of the array in advance, or we need one that can change sizes over the lifetime of a program. |
|
| 5. |
What’s The Base Class Of All Exception Classes? |
|
Answer» Java.Lang.throwable – It is the super CLASS of all exception CLASSES and all exception classes are derived from this BASE class. Java.Lang.throwable – It is the super class of all exception classes and all exception classes are derived from this base class. |
|
| 6. |
Which Api Is Provided By Java For Operations On A Set Of Objects? |
|
Answer» Java PROVIDES a Collection API which provides many USEFUL methods which can be applied to a set of objects. Some of the important classes provided by Collection API INCLUDE ArrayList, HashMap, TreeSet, and TREEMAP. Java provides a Collection API which provides many useful methods which can be applied to a set of objects. Some of the important classes provided by Collection API include ArrayList, HashMap, TreeSet, and TreeMap. |
|
| 7. |
How Can We Find The Actual Size Of An Object On The Heap? |
|
Answer» In JAVA, there is no way to find out 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. |
|
| 8. |
Define An Enumeration? |
|
Answer» 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. 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. |
|
| 9. |
Define Jaxp & Jaxb? |
|
Answer» JAXP: – Stands for Java API for XML Processing. This provides a common interface for creating and using DOM, SAX, and XSLT APIs in Java regardless of which vendor’s implementation is actually being used. JAXP: – Stands for Java API for XML Processing. This provides a common interface for creating and using DOM, SAX, and XSLT APIs in Java regardless of which vendor’s implementation is actually being used. |
|
| 10. |
Explain Struts 1 Classes Are Not Thread Safe Whereas Struts 2 Classes Are Thread Safe? |
|
Answer» STRUTS 1 actions are a singleton. 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. Struts 1 actions are a singleton. 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. |
|
| 11. |
Distinguish Between Static Loading And Dynamic Class Loading? |
|
Answer» Static loading – Classes are loaded STATICALLY with operator “new”. Static loading – Classes are loaded statically with operator “new”. |
|
| 12. |
Java Doesn't Use Pointers. Why? |
|
Answer» Pointers are SUSCEPTIBLE and slight carelessness in their USE may result in memory PROBLEMS and hence JAVA basically manages their use. Pointers are susceptible and slight carelessness in their use may result in memory problems and hence Java basically manages their use. |
|
| 13. |
Describe The Annotations? |
|
Answer» It is a form of METADATA and it provides data about a PROGRAM that is not part of the program itself. An annotation has no direct effect on the operation of the code they annotate. It is a form of metadata and it provides data about a program that is not part of the program itself. An annotation has no direct effect on the operation of the code they annotate. |
|
| 14. |
Define Abstract Class? |
|
Answer» 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). 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). |
|
| 15. |
Can We Import Same Package/class Two Times? Will The Jvm Load The Package Twice At Runtime? |
|
Answer» Yes, we can import the same package/class multiple TIMES. Compiler and JVM are not complaining about it. And the JVM will internally LOAD the class only once no matter how many times we import the same class. Yes, we can import the same package/class multiple times. Compiler and JVM are not complaining about it. And the JVM will internally load the class only once no matter how many times we import the same class. |
|
| 16. |
Define Content Negotiation? |
|
Answer» 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. 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. |
|
| 17. |
Name The Methods Of Object Class? |
|
Answer» CLONE() – This method helps to create and return a copy of the object. clone() – This method helps to create and return a copy of the object. |
|
| 18. |
What Are The Advantages Of Json Over Xml? |
|
Answer» The ADVANTAGES of JSON over XML are The advantages of JSON over XML are |
|
| 19. |
Define Json? |
|
Answer» Expansion of JSON is “JavaScript Object Notation”, It is a much lighter and readable ALTERNATIVE to XML. It is an INDEPENDENT and easily parse-able in all PROGRAMMING languages. It is primarily used for Communicating between CLIENT – server or server -server communication. It is a much lighter and readable alternative to XML. Expansion of JSON is “JavaScript Object Notation”, It is a much lighter and readable alternative to XML. It is an independent and easily parse-able in all programming languages. It is primarily used for Communicating between client – server or server -server communication. It is a much lighter and readable alternative to XML. |
|
| 20. |
Are Constructors Inherited? Can A Subclass Call The Parent’s Class Constructor? |
|
Answer» We cannot inherit a CONSTRUCTOR. We create an instance of a subclass using a constructor of one of its superclass. Because OVERRIDE the superclass constructor is not our wish so that, we override a superclass constructor, then we destroy the ENCAPSULATION abilities of the LANGUAGE. We cannot inherit a constructor. We create an instance of a subclass using a constructor of one of its superclass. Because override the superclass constructor is not our wish so that, we override a superclass constructor, then we destroy the encapsulation abilities of the language. |
|
| 21. |
How Can We Fetch Records By Spring Jdbctemplate? |
|
Answer» We can fetch records from the DATABASE by the query method of JdbcTemplate. There are TWO INTERFACES to do this: We can fetch records from the database by the query method of JdbcTemplate. There are two interfaces to do this: |
|
| 22. |
What Is A Function Of Ioc Container In Spring? |
|
Answer» IOC container is responsible to: IOC container is responsible to: |
|
| 23. |
Define A Cookie And What Are The Difference Between Session And Cookie? |
|
Answer» 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. 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. |
|
| 24. |
Define The Implicit Object? |
|
Answer» JSP IMPLICIT OBJECTS are those Java objects that the JSP Container makes available to developers in every PAGE. A developer can able to CALL them directly, without being explicitly declared. JSP Implicit Objects are also known as pre-defined variables. The following objects are considered implicit in a JSP page: JSP implicit objects are those Java objects that the JSP Container makes available to developers in every page. A developer can able to call them directly, without being explicitly declared. JSP Implicit Objects are also known as pre-defined variables. The following objects are considered implicit in a JSP page: |
|
| 25. |
Explain Expression Language In Jsp? |
|
Answer» 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. 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. |
|
| 26. |
What Are The Differences Between The Jsp Custom Tags & Java Beans? |
|
Answer» • Custom tags can manipulate JSP content, but BEANS cannot. • Custom tags can manipulate JSP content, but beans cannot. |
|
| 27. |
What Are The Functions Of Hashcode() Method? |
| Answer» | |
| 28. |
Mention The Uses Of Synchronized Block |
|
Answer» We are using SYNCHRONIZED block because We are using Synchronized block because |
|
| 29. |
Write A Code To Make Collections Readonly? |
|
Answer» We can make the Collection readOnly by USING the following lines code: General : Collections.unmodifiableCollection(Collection c)Collections.unmodifiableMap(MAP m) Collections.unmodifiableList(List L) Collections.unmodifiableSet(Set s) We can make the Collection readOnly by using the following lines code: General : Collections.unmodifiableCollection(Collection c)Collections.unmodifiableMap(Map m) Collections.unmodifiableList(List l) Collections.unmodifiableSet(Set s) |
|
| 30. |
Write A Syntax To Convert A Given Collection To Synchronizedcollection ? |
|
Answer» Collections.synchronizedCollection(COLLECTION collectionObj) will CONVERT a GIVEN collection to SYNCHRONIZED collection. Collections.synchronizedCollection(Collection collectionObj) will convert a given collection to synchronized collection. |
|
| 31. |
What Is Hash-collision In Hashtable? How Was It Handled In Java? |
|
Answer» In Hashtable , if two different KEYS have the same HASH value then it leads to hash -collision. A BUCKET of type LINKED LIST used to hold the different keys of same hash value. In Hashtable , if two different keys have the same hash value then it leads to hash -collision. A bucket of type linked list used to hold the different keys of same hash value. |
|
| 32. |
How To Make An Immutable Class In Hibernate? |
|
Answer» If we MARK a class as mutable=”false”, the class will be TREATED as an immutable class. The DEFAULT VALUE of mutable is “true”. If we mark a class as mutable=”false”, the class will be treated as an immutable class. The default value of mutable is “true”. |
|
| 33. |
What Are The States Of An Object In Hibernate? |
|
Answer» The states of an object in hibernate are
Transient: The object is in the transient STATE if it is just CREATED but has no primary key (IDENTIFIER) and it is not associated with the session. The states of an object in hibernate are Transient: The object is in the transient state if it is just created but has no primary key (identifier) and it is not associated with the session. |
|
| 34. |
What Is The Front Controller Class Of Spring Mvc? |
|
Answer» The DISPATCHER Servlet class works as the front CONTROLLER in SPRING MVC. The Dispatcher Servlet class works as the front controller in Spring MVC. |
|
| 35. |
What Is Meant By Binding In Rmi? |
|
Answer» BINDING is the process of ASSOCIATING or REGISTERING a name for a REMOTE object, which can be used as a further, in ORDER to look up that remote object. A remote object can be associated with a name using the bind / rebind methods of the Naming class. Binding is the process of associating or registering a name for a remote object, which can be used as a further, in order to look up that remote object. A remote object can be associated with a name using the bind / rebind methods of the Naming class. |
|
| 36. |
Write A Code To Sort A List Of Strings Using Java 8 Lambda Expression? |
|
Answer» . PRIVATE void sortUsingJava8(List NAMES){ Collections.sort(names, (p1, P2) -> p1.compareTo(p2)); } . private void sortUsingJava8(List names){ Collections.sort(names, (p1, p2) -> p1.compareTo(p2)); } |
|
| 37. |
What Is "application Assembler"? |
|
Answer» A PERSON who COMBINES J2EE components and modules into deployable application UNITS. A person who combines J2EE components and modules into deployable application units. |
|
| 38. |
What Is Authentication? |
|
Answer» The process that verifies the identity of a user, DEVICE, or other entity in a computer SYSTEM, usually as a prerequisite to allowing access to resources in a system. The Java servlet specification requires THREE TYPES of AUTHENTICATION-basic, form-based, and mutual-and supports digest authentication. The process that verifies the identity of a user, device, or other entity in a computer system, usually as a prerequisite to allowing access to resources in a system. The Java servlet specification requires three types of authentication-basic, form-based, and mutual-and supports digest authentication. |
|
| 39. |
What Is "attribute"? |
|
Answer» A QUALIFIER on an XML TAG that PROVIDES ADDITIONAL INFORMATION. A qualifier on an XML tag that provides additional information. |
|
| 40. |
What Is "asant"? |
|
Answer» A Java-based BUILD tool that can be extended USING Java CLASSES. The CONFIGURATION files are XML-based, calling out a target tree where various tasks GET executed.
A Java-based build tool that can be extended using Java classes. The configuration files are XML-based, calling out a target tree where various tasks get executed.
|
|
| 41. |
What Is "archiving"? |
|
Answer» The PROCESS of SAVING the STATE of an OBJECT and RESTORING it. The process of saving the state of an object and restoring it. |
|
| 42. |
What Is "application Configuration Resource File"? |
|
Answer» An XML file used to CONFIGURE RESOURCES for a Java Server Faces application, to define NAVIGATION rules for the application, and to register converters, Validator, listeners, RENDERS, and components with the application. An XML file used to configure resources for a Java Server Faces application, to define navigation rules for the application, and to register converters, Validator, listeners, renders, and components with the application. |
|
| 43. |
What Is "application Component Provider"? |
|
Answer» A VENDOR that provides the Java CLASSES that implement COMPONENTS' methods, JSP page definitions, and any REQUIRED deployment descriptors. A vendor that provides the Java classes that implement components' methods, JSP page definitions, and any required deployment descriptors. |
|
| 44. |
What Is "application Client Module"? |
|
Answer» A software UNIT that consists of one or more CLASSES and an APPLICATION client DEPLOYMENT descriptor. A software unit that consists of one or more classes and an application client deployment descriptor. |
|
| 45. |
What Is "application Client Container"? |
|
Answer» A CONTAINER that SUPPORTS APPLICATION CLIENT COMPONENTS. A container that supports application client components. |
|
| 46. |
What Is "application Client"? |
|
Answer» A first-tier J2EE CLIENT component that executes in its own Java VIRTUAL machine. Application clients have ACCESS to some J2EE platform APIs. A first-tier J2EE client component that executes in its own Java virtual machine. Application clients have access to some J2EE platform APIs. |
|
| 47. |
What Is Java Server Pages Standard Tag Library (jstl)? |
|
Answer» A tag library that encapsulates core functionality common to many JSP applications. JSTL has support for common, structural tasks such as iteration and conditionals, TAGS for manipulating XML documents, internationalization and locale-specific FORMATTING tags, SQL tags, and functions. A tag library that encapsulates core functionality common to many JSP applications. JSTL has support for common, structural tasks such as iteration and conditionals, tags for manipulating XML documents, internationalization and locale-specific formatting tags, SQL tags, and functions. |
|
| 48. |
What Is Java Server Pages (jsp)? |
|
Answer» An extensible Web TECHNOLOGY that uses static DATA, JSP elements, and server-side JAVA objects to generate dynamic content for a client. Typically the static data is HTML or XML elements, and in MANY cases the client is a Web browser. An extensible Web technology that uses static data, JSP elements, and server-side Java objects to generate dynamic content for a client. Typically the static data is HTML or XML elements, and in many cases the client is a Web browser. |
|
| 49. |
What Is Javaserver Faces Expression Language? |
|
Answer» A SIMPLE expression LANGUAGE used by a JavaServer Faces UI component tag attributes to bind the associated component to a bean property or to bind the associated component's value to a method or an external data SOURCE, such as a bean property. Unlike JSP EL expressions, JavaServer Faces EL expressions are EVALUATED by the JavaServer Faces implementation rather than by the Web CONTAINER. A simple expression language used by a JavaServer Faces UI component tag attributes to bind the associated component to a bean property or to bind the associated component's value to a method or an external data source, such as a bean property. Unlike JSP EL expressions, JavaServer Faces EL expressions are evaluated by the JavaServer Faces implementation rather than by the Web container. |
|
| 50. |
What Exceptions Do The Dao Classes, Use In Spring Throw? |
|
Answer» In SPRING DAO CLASSES only THROWS SQLEXCEPTION. In spring DAO classes only throws SQLException. |
|