Java Programming MCQ (Multiple Choice Questions) - SchoolingAxis

Java Programming MCQ (Multiple Choice Questions)

 Que-  Which of the following is not an advantage of using Hibernate Query Language?

a. Database independent

b. Easy to write query

c. No need to learn SQL

d. Difficult to implement


Answer- Difficult to implement


Que-  In which file database table configuration is stored?

a. .dbm

b. .hbm

c. .ora

d. .sql


Answer- .hbm


Que-  Which of the following is not an advantage of Hibernate Criteria API?

a. Allows to use aggregate functions

b. Cannot order the result set

c. Allows to fetch only selected columns of result

d. Can add conditions while fetching results


Answer- Cannot order the result set


Que-  What does Liskov substitution principle specify?

a. parent class can be substituted by child class

b. child class can be substituted by parent class

c. parent class cannot be substituted by child class

d. No classes can be replaced by each other


Answer- parent class can be substituted by child class


Que-  What should the return type of method where there is no return value?

a. Null

b. Empty collection

c. Singleton collection

d. Empty String


Answer- Empty collection


Que-  What data structure should be used when number of elements is fixed?

a. Array

b. Array list

c. Vector

d. Set


Answer- Array


Que-  What causes the program to exit abruptly and hence its usage should be minimalistic?

a. Try

b. Finally

c. Exit

d. Catch


Answer- Exit


Que-  Which one of the following causes memory leak?

a. Release database connection when querying is complete

b. Use Finally block as much as possible

c. Release instances stored in static tables

d. Not using Finally block often


Answer- Not using Finally block often


Que-  Which of the following is a best practice to measure time taken by a process for execution?

a. System.currentTimeMillis()

b. System.nanoTime()

c. System.getCurrentTime()

d. System.getProcessingTime()


Answer- System.nanoTime()


Que-  Which of the below is true about java class structure?

a. The class name should start with lowercase

b. The class should have thousands of lines of code

c. The class should only contain those attribute and functionality which it should; hence keeping it short

d. The class attributes and methods should be public


Answer- The class should only contain those attribute and functionality which it should; hence keeping it short


Que-  Which of the below is false about java coding?

a. variable names should be short

b. variable names should be such that they avoid ambiguity

c. test case method names should be created as english sentences without spaces

d. class constants should be used when we want to share data between class methods


Answer- variable names should be short


Que-  Which is better in terms of performance for iterating an array?

a. for(int i=0; i<100; i++)

b. for(int i=99; i>=0; i–)

c. for(int i=100; i<0; i++)

d. for(int i=99; i>0; i++)


Answer- for(int i=99; i>=0; i–)


Que-  Which of the following is not an Enterprise Beans type?

a. Doubleton

b. Singleton

c. Stateful

d. Stateless


Answer- Doubleton


Que-  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 properties


Answer- Extends java.io.Serializable class


Que-  Which file separator should be used by MANIFEST file?

a. /

b. \

c. –

d. //


Answer- /


Que-  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.DuplicateClassError


Answer- java.lang.ClassFormatError


Que-  Java Beans are extremely secured?

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-FALSE


Que-  Which of the following is not a feature of Beans?

a. Introspection

b. Events

c. Persistence

d. Serialization


Answer- Serialization


Que-  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. session


Answer- singleton


Que-  Which attribute is used to specify initialization method?

a. init

b. init-method

c. initialization

d. initialization-method


Answer- init-method


Que-  Which attribute is used to specify destroy method?

a. destroy

b. destroy-method

c. destruction

d. destruction-method


Answer- destroy-method


Que-  How to specify autowiring by name?

a. @Qualifier

b. @Type

c. @Constructor

d. @Name


Answer- @Qualifier


Que-  Which of the following contains both date and time?

a. java.io.date

b. java.sql.date

c. java.util.date

d. java.util.dateTime


Answer- java.util.dateTime


Que-  Which of the following is advantage of using JDBC connection pool?

a. Slow performance

b. Using more memory

c. Using less memory

d. Better performance


Answer- Better performance


Que-  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 usage


Answer- Prevents SQL injection


Que-  Which one of the following contains date information?

a. java.sql.TimeStamp

b. java.sql.Time

c. java.io.Time

d. java.io.TimeStamp


Answer- java.sql.TimeStamp


Que-  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 transaction


Answer- does not commit transaction automatically after each query


Que-  Which of the following is used to call stored procedure?

a. Statement

b. PreparedStatement

c. CallableStatment

d. CalledStatement


Answer- CallableStatment


Que-  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)


Answer- setMaxRows(int i)


Que-  Which of the following is method of JDBC batch process?

a. setBatch()

b. deleteBatch()

c. removeBatch()

d. addBatch()


Answer- addBatch()


Que-  Which of the following is used to rollback a JDBC transaction?

a. rollback()

b. rollforward()

c. deleteTransaction()

d. RemoveTransaction()


Answer- rollback()


Que-  Which of the following is not a JDBC connection isolation levels?

a. TRANSACTION_NONE

b. TRANSACTION_READ_COMMITTED

c. TRANSACTION_REPEATABLE_READ

d. TRANSACTION_NONREPEATABLE_READ


Answer- TRANSACTION_NONREPEATABLE_READ


Que-  Which of the below is not a valid design pattern?

a. Singleton

b. Factory

c. Command

d. Java


Answer- Java


Que-  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 Johnson


Answer- Gang Pattern


Que-  Which of the below is not a valid classification of design pattern?

a. Creational patterns

b. Structural patterns

c. Behavioural patterns

d. Java patterns


Answer- Java patterns


Que-  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 pattern


Answer- Facade pattern


Que-  Which design pattern ensures that only one object of particular class gets created?

a. Singleton pattern

b. Filter pattern

c. State pattern

d. Bridge pattern


Answer- Singleton pattern


Que-  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 pattern


Answer- Chain of responsibility pattern


Que-  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 pattern


Answer- Iterator pattern


Que-  What does MVC pattern stands for?

a. Mock View Control

b. Model view Controller

c. Mock View Class

d. Model View Class


Answer- Model view Controller


Que-  Is design pattern a logical concept.

a.TRUE

b.FALSE

c.Nothing Can be Said

d.None of the mentioned


Answer-TRUE


Que-  Which design pattern works on data and action taken based on data provided?

a. Command pattern

b. Singleton pattern

c. MVC pattern

d. Facade pattern


Answer- Command pattern


Que-  Which mode allows us to run program interactively while watching source code and variables during execution?

a. safe mode

b. debug mode

c. successfully run mode

d. exception mode


Answer- debug mode


Que-  How can we move from one desired step to another step?

a. breakpoints

b. System.out.println

c. logger.log

d. logger.error


Answer- breakpoints


Que-  Which part stores the program arguments and startup parameters?

a. debug configuration

b. run configuration

c. launch configuration

d. project configuration


Answer- launch configuration


Que-  How to deep dive into the execution of a method from a method call?

a. F3

b. F5

c. F7

d. F8


Answer- F5


Que-  Which key helps to step out of the caller of currently executed method?

a. F3

b. F5

c. F7

d. F8


Answer- F7


Que-  Which view allows us to delete and deactivate breakpoints and watchpoints?

a. breakpoint view

b. variable view

c. debug view

d. logger view


Answer- breakpoint view


Que-  What is debugging an application which runs on another java virtual machine on another machine?

a. virtual debugging

b. remote debugging

c. machine debugging

d. compiling debugging


Answer- remote debugging


Que-  What happens when the value of variable change?

a. changed value pop on the screen

b. variable changes are printed in logs

c. dump of variable changes are printed on the screen on end of execution

d. variable tab shows variables highlighted when values change


Answer- variable tab shows variables highlighted when values change


Que-  Which perspective is used to run a program in debug view?

a. java perspective

b. eclipse perspective

c. debug perspective

d. jdbc perspective


Answer- debug perspective


Que-  How does eclipse provide the capability for debugging browser actions?

a. internal web browser

b. chrome web browser

c. firefox web browser

d. internet explorer browser


Answer- internal web browser


Que-  Servlet are used to program which component in a web application?

a. client

b. server

c. tomcat

d. applet


Answer- server

Previous Post Next Post