Explore topic-wise InterviewSolutions in .

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.

Is design pattern a logical concept.(a) True(b) FalseThe question was asked by my college director while I was bunking the class.The query is from Design Patterns topic in division Java Beans & JDBC of Java

Answer» CORRECT choice is (a) True

Easiest EXPLANATION: DESIGN PATTERN is a LOGICAL concept. Various classes and frameworks are provided to enable users to implement these design patterns.
2.

What does MVC pattern stands for?(a) Mock View Control(b) Model view Controller(c) Mock View Class(d) Model View ClassI got this question during an online exam.The doubt is from Design Patterns in division Java Beans & JDBC of Java

Answer»

Correct answer is (b) Model view Controller

The best I can EXPLAIN: Model REPRESENTS an OBJECT or JAVA POJO carrying data.View represents the visualization of the data that model contains. The controller acts on both model and view. It is usually used in web development.

3.

Which design pattern represents a way to access all the objects in a collection?(a) Iterator pattern(b) Facade pattern(c) Builder pattern(d) Bridge patternThe question was asked in an international level competition.My question is from Design Patterns in chapter Java Beans & JDBC of Java

Answer»

Right option is (a) ITERATOR pattern

The EXPLANATION is: Iterator pattern represents a way to ACCESS the elements of a collection object in sequential manner without the need to know its UNDERLYING REPRESENTATION.

4.

Which design pattern suggests multiple classes through which request is passed and multiple but only relevant classes carry out operations on the request?(a) Singleton pattern(b) Chain of responsibility pattern(c) State pattern(d) Bridge patternThis question was addressed to me in final exam.The query is from Design Patterns topic in section Java Beans & JDBC of Java

Answer»

The CORRECT choice is (b) CHAIN of RESPONSIBILITY pattern

The explanation: Chain of responsibility pattern creates a chain of RECEIVER objects for a particular request. The sender and receiver of a request are DECOUPLED based on the type of request. This pattern is one of the behavioral patterns.

5.

Which of the below is not a valid design pattern?(a) Singleton(b) Factory(c) Command(d) JavaI got this question in semester exam.My question is based upon Design Patterns in section Java Beans & JDBC of Java

Answer»

The correct answer is (d) Java

To ELABORATE: Design pattern is a general repeatable solution to a commonly occurring problem in software design. There are various patterns available for USE in day to day CODING PROBLEMS.

6.

Which design pattern ensures that only one object of particular class gets created?(a) Singleton pattern(b) Filter pattern(c) State pattern(d) Bridge patternThis question was addressed to me during an interview.Query is from Design Patterns topic in section Java Beans & JDBC of Java

Answer»

Right answer is (a) Singleton pattern

To ELABORATE: Singleton pattern involves a single class which is responsible to create an object while making sure that only one object GETS created. This class provides a way to access the only object which can be accessed DIRECTLY without need to INSTANTIATE another object of the same class.

7.

Which design pattern provides a single class which provides simplified methods required by client and delegates call to those methods?(a) Adapter pattern(b) Builder pattern(c) Facade pattern(d) Prototype patternThe question was asked in an interview for job.I would like to ask this question from Design Patterns topic in portion Java Beans & JDBC of Java

Answer»

The correct choice is (c) Facade PATTERN

Explanation: Facade pattern HIDES the complexities of the system and provides an interface to the client USING which client can access the system.

8.

Which of the below is not a valid classification of design pattern?(a) Creational patterns(b) Structural patterns(c) Behavioural patterns(d) Java patternsI have been asked this question in an interview.This question is from Design Patterns topic in division Java Beans & JDBC of Java

Answer»

The CORRECT OPTION is (d) JAVA patterns

Explanation: Java patterns is not a valid CLASSIFICATION of DESIGN patterns. The correct one is J2EE patterns.

9.

Which of the below author is not a part of GOF (Gang of Four)?(a) Erich Gamma(b) Gang Pattern(c) Richard Helm(d) Ralph JohnsonThis question was posed to me in a job interview.My query is from Design Patterns in section Java Beans & JDBC of Java

Answer» CORRECT OPTION is (b) Gang Pattern

The explanation: Four authors named Richard Helm, Erich Gamma, Ralph Johnson and John Vlissides published a book on design patterns. This book initiated the concept of Design Pattern in SOFTWARE development. They are KNOWN as Gang of Four (GOF).
10.

Which of the following is method of JDBC batch process?(a) setBatch()(b) deleteBatch()(c) removeBatch()(d) addBatch()I got this question in quiz.Enquiry is from JDBC topic in division Java Beans & JDBC of Java

Answer»

The correct answer is (d) addBatch()

To explain: addBatch() is a METHOD of JDBC batch process. It is faster in PROCESSING than executing one statement at a TIME.

11.

Which of the following is used to rollback a JDBC transaction?(a) rollback()(b) rollforward()(c) deleteTransaction()(d) RemoveTransaction()The question was posed to me in an internship interview.This intriguing question originated from JDBC in section Java Beans & JDBC of Java

Answer» CORRECT answer is (a) rollback()

To EXPLAIN: rollback() method is USED to rollback the transaction. It will rollback all the changes MADE by the transaction.
12.

What does setAutoCommit(false) do?(a) commits transaction after each query(b) explicitly commits transaction(c) does not commit transaction automatically after each query(d) never commits transactionThe question was posed to me in an online quiz.The query is from JDBC topic in portion Java Beans & JDBC of Java

Answer»

Correct choice is (c) does not commit TRANSACTION automatically after each query

To EXPLAIN I would say: setAutoCommit(FALSE) does not commit transaction automatically after each query. That saves a LOT of time of the execution and hence improves performance.

13.

Which of the following is used to call stored procedure?(a) Statement(b) PreparedStatement(c) CallableStatment(d) CalledStatementI have been asked this question in an online quiz.My question is taken from JDBC in section Java Beans & JDBC of Java

Answer»

The CORRECT option is (c) CallableStatment

Easiest explanation: CALLABLESTATEMENT is used in JDBC to call stored PROCEDURE from Java program.

14.

Which of the following is used to limit the number of rows returned?(a) setMaxRows(int i)(b) setMinRows(int i)(c) getMaxrows(int i)(d) getMinRows(int i)I have been asked this question during an interview.My question is based upon JDBC topic in chapter Java Beans & JDBC of Java

Answer»

Correct ANSWER is (a) setMaxRows(INT i)

To explain: setMaxRows(int i) METHOD is used to limit the NUMBER of rows that the database returns from the query.

15.

Which one of the following contains date information?(a) java.sql.TimeStamp(b) java.sql.Time(c) java.io.Time(d) java.io.TimeStampThis question was posed to me in an interview for internship.My doubt is from JDBC in portion Java Beans & JDBC of Java

Answer»

Right answer is (a) java.sql.TimeStamp

Best explanation: java.sql.TIME CONTAINS only time. WHEREAS, java.sql.TimeStamp contains both time and DATE.

16.

Which of the following is advantage of using PreparedStatement in Java?(a) Slow performance(b) Encourages SQL injection(c) Prevents SQL injection(d) More memory usageI got this question by my school principal while I was bunking the class.My question is taken from JDBC in division Java Beans & JDBC of Java

Answer»

Correct CHOICE is (C) Prevents SQL injection

Easiest EXPLANATION: PreparedStatement in Java improves performance and ALSO prevents from SQL injection.

17.

Which of the following is advantage of using JDBC connection pool?(a) Slow performance(b) Using more memory(c) Using less memory(d) Better performanceI had been asked this question in semester exam.Query is from JDBC topic in section Java Beans & JDBC of Java

Answer»

The correct choice is (d) BETTER performance

To EXPLAIN I would say: SINCE the JDBC connection takes time to ESTABLISH. Creating connection at the application start-up and reusing at the time of requirement, helps performance of the application.

18.

Which of the following contains both date and time?(a) java.io.date(b) java.sql.date(c) java.util.date(d) java.util.dateTimeI had been asked this question in final exam.This question is from JDBC topic in portion Java Beans & JDBC of Java

Answer»

Correct answer is (d) java.util.dateTime

Easiest EXPLANATION: java.util.DATE CONTAINS both date and time. WHEREAS, java.sql.date contains only date.

19.

Which attribute is used to specify destroy method?(a) destroy(b) destroy-method(c) destruction(d) destruction-methodI had been asked this question in final exam.This intriguing question comes from Java Beans in chapter Java Beans & JDBC of Java

Answer» RIGHT OPTION is (b) destroy-method

Easy EXPLANATION: destroy-method is used to specify the DESTRUCTION method.
20.

Which attribute is used to specify initialization method?(a) init(b) init-method(c) initialization(d) initialization-methodThe question was asked in semester exam.The above asked question is from Java Beans topic in section Java Beans & JDBC of Java

Answer»

The correct CHOICE is (b) init-method

Best explanation: init-method is USED to specify the INITIALIZATION method.

21.

What is the attribute of java bean to specify scope of bean to have single instance per Spring IOC?(a) prototype(b) singleton(c) request(d) sessionI had been asked this question at a job interview.The question is from Java Beans in division Java Beans & JDBC of Java

Answer» CORRECT OPTION is (B) singleton

Explanation: Singleton scope of BEAN specifies only one instance per SPRING IOC container. This is the default scope.
22.

Java Beans are extremely secured?(a) True(b) FalseI got this question in unit test.Question is taken from Java Beans topic in portion Java Beans & JDBC of Java

Answer» CORRECT choice is (b) False

For explanation: JAVABEANS do not add any security features to the JAVA platform.
23.

Which of the following is not a feature of Beans?(a) Introspection(b) Events(c) Persistence(d) SerializationThe question was posed to me in unit test.The question is from Java Beans topic in section Java Beans & JDBC of Java

Answer»

Correct CHOICE is (d) Serialization

Best explanation: Serialization is not the FEATURE of JAVA Beans. Introspection, CUSTOMIZATION, Events, Properties and PERSISTENCE are the features.

24.

Which of the following is correct error when loading JAR file with duplicate name?(a) java.io.NullPointerException(b) java.lang.ClassNotFound(c) java.lang.ClassFormatError(d) java.lang.DuplicateClassErrorThe question was posed to me in an international level competition.I'm obligated to ask this question of Java Beans topic in chapter Java Beans & JDBC of Java

Answer»

Correct option is (c) java.lang.ClassFormatError

To ELABORATE: java.lang.ClassFormatError: Duplicate NAME ERROR is thrown when .class FILE in the JAR contains a class WHOSE class name is different from the expected name.

25.

Which file separator should be used by MANIFEST file?(a) /(b) \(c) –(d) //The question was asked during an online interview.This key question is from Java Beans in chapter Java Beans & JDBC of Java

Answer»

Correct option is (a) /

The BEST I can explain: MANIFEST file uses CLASSES using / file separator.

26.

Which of the following is not true about Java beans?(a) Implements java.io.Serializable interface(b) Extends java.io.Serializable class(c) Provides no argument constructor(d) Provides setter and getter methods for its propertiesI got this question by my college director while I was bunking the class.Origin of the question is Java Beans in section Java Beans & JDBC of Java

Answer»

Right choice is (B) EXTENDS java.io.Serializable CLASS

Best explanation: java.io.Serializable is not a class. Instead it is an INTERFACE. Hence it cannot be EXTENDED.

27.

Which of the following is not an Enterprise Beans type?(a) Doubleton(b) Singleton(c) Stateful(d) StatelessI have been asked this question in an online quiz.This is a very interesting question from Java Beans topic in chapter Java Beans & JDBC of Java

Answer» RIGHT OPTION is (a) Doubleton

Explanation: STATEFUL, Stateless and SINGLETON are session beans.