0% found this document useful (0 votes)
54 views12 pages

Modified PDF R

The document contains questions about Java and JDBC concepts. It asks about code snippets involving JSP tags, JDBC statements, and Java code. It also contains questions about design patterns, UML diagrams, Java classes and interfaces, and Java language features like streams and annotations.

Uploaded by

Uttara B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views12 pages

Modified PDF R

The document contains questions about Java and JDBC concepts. It asks about code snippets involving JSP tags, JDBC statements, and Java code. It also contains questions about design patterns, UML diagrams, Java classes and interfaces, and Java language features like streams and annotations.

Uploaded by

Uttara B
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 12

1.) Which statements are correct for given code fragment?

<c:set var="eight">
<c:out value="${4 * 2}"/>
</c:set>

A. Syntax is not valid for this tag.


B. It prints 8 as output.
C. This tag creates a page-scoped variable named eight and sets it to the string 8
D. Error
a)A and B
b)B and C
c)C and D
d)A and D

2.) What gets printed when the following expression is evaluated?


${4 div 5}

a)0
b)0.8
c)1
d)1.8

3.) How can you execute DML statements (i.e. insert, delete, update) in
the database?

a) By making use of the InsertStatement, DeleteStatement or


UpdateStatement classes
b) By invoking the execute(...) or executeUpdate(...) method of a normal
Statement object or a sub-interface object thereof
c) By invoking the executeInsert(...), executeDelete(...) or executeUpdate(...) methods of
the DataModificationStatement object.
d) By making use of the execute(...) statement of the DataModificationStatement object.

4.) Which type of Statement can execute parameterized queries?

a) PreparedStatement
b) ParameterizedStatement
c) ParameterizedStatement and CallableStatement
d) All kinds of Statements (i.e. which implement a sub interface of Statement)
5.) To execute stored procedure total Stock in a database server, which of the following
code snippet is used?

a)Statement stmt = connection.createStatement(); stmt.execute("totalStock()");


b)CallableStatement clbstmnt = con.prepareCall("{call totalStock}"); cs.executeQuery();
c)StoreProcedureStatement spstmt = connection.createStoreProcedure("totalStock()");
spstmt.executeQuery();
d)PrepareStatement pstmt = connection.prepareStatement("totalStock()"); pstmt.execute();

6.) When a select statement returns only one record with a single column of integer
datatype on invoking resultset.getint(0) causes_____________

a)Returns the first integer value


b)Returns Null
c)throws “java.sql.SQLException: Invalid data type”
d) throws “java.sql.SQLException Invalid column index”

7.) What is the use of setAutoCommit(false) in JDBC?

a)It ensures to commit transaction automatically after each query.


b)It doesn’t commit transaction automatically after each query.
c)It rolls back the transaction.
d)It will not execute the query.

8.) Which of the following describes the correct sequence of the steps involved in making
a connection with a database.

1. Loading the driver


2. Process the results.
3. Making the connection with the database.
4. Executing the SQL statements.

a) 1,2,3,4
b) 1,3,4,2
c) 2,1,3,4
d) 4,1,2,3

9.) Which of the following is a behavioral UML diagram?

a)Use Case diagram


b)Package diagram
c) Profile diagram
d)Object diagram
10.) Fill in the blank.
The meaning of 1..* in UML is -----------------

a)Exactly one instance.


b)No limit on number of instances.
c)Atleast one instance.
d)More than one instance.

11.) Fill in the blank.


The function of AbstractFactory is to -------------

a) Provide an interface for creating families of related objects without specifying their
concrete classes.
b) Declare an interface for operations that create abstract products.
c) Declare an interface for a type of product objects.
d) Implement the AbstractProduct interface.

12.) When would you apply the builder design pattern?

a) When you want to provide a collection of classes, you want to reveal just their contracts
and their relationships, not their implementations.
b) When you want to use an existing class, and its interface doesnot match the one you
need.
c) When you need to add responsibilities to individual objects dynamically without
affecting other objects.
d) When you want to separate abstraction and implementation permanently and need
to share an implementation among multiple objects.

13.) A JSP page uses the java.util.ArrayList class many times. Instead of referring the class
by its complete package name each time, we want to just use ArrayList. Which attribute of
page directive must be specified to achieve this. Select the one correct answer.

a) extends
b) import
c) include
d) package
e) class path

14.) Which of the following is used to redirect the response from a servlet to a JSP page?

a) response.sendRedirect()
b) request.sendRedirect()
c) request.forward()
d) response.forward()
15.) Which of the following options represents the XML equivalent of this statement?

<%@ includefile="a.jsp"%>

a) <jsp:includefile="a.jsp"/>
b) <jsp:includepage="a.jsp"/>
c) <jsp:directive.includefile="a.jsp"/>
d) There is no XML equivalent of include directive

16.) What gets printed when the following is compiled?

<% int y = 0; %>


<% int z = 0; %> <% for(int x=0;x<3;x++) { %>
<% z++;++y;%>
<% }%>

<% if(z<y) {%>


<%= z%>
<% } else {%>
<%= z - 1%>
<% }%>
a) 0
b) 1
c) 2
d) 3

17.) If in test.jsp

\${3+2-1}: ${3+2-1}

What is the output?

a) ${3+2-1}: 4
b) \${3+2-1}: 4
c) \${4}: 4
d) ${4}: 4

18.) How to initialize a servlet?

1.Byusingconstructor
2.Byusinginit
3.Alloftheabove
4.Noneoftheabove
19.) Which of these are common mechanisms for session tracking?

Cookies
URL rewriting
Hidden Form field
All of the above

20.) A user types the URL in a browser:

http://www.javatraining.com/GH/index.html. Which HTTP request gets generated?

a) GETmethod
b) POSTmethod
c) HEADmethod
d) PUTmethod

21.) GET is used to get data from Client and POST is used to post data to client.

a) This statement is true


b) This statement is false
c) The statement can be true sometimes
d) None of the above

22.) A Java bean with a property color is loaded using the following statement:

<jsp:usebean id="fruit" class="Fruit"/>

What is the effect of the following statement?


<jsp:setproperty name="fruit" property="color"/>

An error gets generated because the value attribute of setAttribute is not defined.
The color attribute is assigned a value null.
The color attribute is assigned a value "".
If there is a non-null request parameter with name color, then its value gets assigned to
color property of Java Bean fruit.

23.) Fill in the blank.

When using the <jsp:useBean/> to reference a Java Bean for use within a JSP, the id
attribute defines _______________.

a) The class name of the JavaBean


b) The package name of the JavaBean
c) The instance name of the JavaBean
d)Defines nothing as there is no id attribute
24.) Which listener(s) is used to track session attribute?

a) Http Session Binding Listener


b) Http Session Attribute Listener
c) Http Session Listener
d) All of the above

25. ) Which of the following should be used to find total number of users?

a) ServletRequestListener
b) ServletContextListener
c) HTTPSessionListener
d) HTTPSessionBindingListener

26.) What is the sequence of method execution in Filter?

a) init, doFilter, destroy


b) doFilter, init, destroy
c) destroy, doFilter, init
d) destroy, doFilter

27.) If we run the test suite as junit test, what will be the order of execution of all the four
test classes

RunWith(Suite.class)
@SuiteClasses({
annotationTest.class,
AssertTest.class
CalculateTest.class,
EmployeeTest.class
})

a) 1. AnnotationTest, 2. CalculateTest, 3. EmployeeTest, 4. AsserTest,


b) 1. AnnotationTest, 2. AsserTest, 3. CalculateTest, 4. EmployeeTest
c) 1. AnnotationTest, 2. CalculateTest, 3. AsserTest, 4. EmployeeTest
d) 1. EmployeeTest, 2. CalculateTest, 3. AsserTest, 4. AnnotationTest

28.) Which of the following method of Assert class checks that an object is null?

a) void assert(Object object,Boolean toCheckAsNull)


b) void assertCheck(Object object, Boolean toCheckAsNull)
c) void assertNull(Object object)
d) void assertChecks(Object object, Boolean toCheckAsNull
29.) What is the replacement for PermGen space in java8?

a)FixedGen
b)Metaspace
c)MetaGenspace

30.) What is the output of the following Java code snippet?

StringJoiner astring = new StringJoiner("-", "{", "}");

astring.add("A");
astring.add("B");
astring.add("C");

a) {A-B-C}
b) {A}-{B}-{C}
c) {-A-}{-B-}{-C-}

31.) Which java set implementation is sorted & synchronized?

a) TreeSet
b) LinkedHashSet
c) HashSet
d) concurrentSkipListSet

32.) Pick the class that is NOT part of java collection framework>!

a) Map
b) List
c) Queue
d) Struct

33.) What is the return type of Java Lambda expressions?

a) Void
b) Lambda
c) Function
d) Regex

34.) HTTP2 Client API is introduced in java9.

a) True
b) False
35.) Name the two types of streams in Java.
a) Sync and async
b) Sequential and parallel
c) Random and ordered

36.) What is the difference between peak() and dequeue()?

a) Peek() returns the next item in line but dequeue() removes and returns the next item in
line
b) peek() and dequeue() return the next item in line
c) peek() and dequeue remove and return the next item in line

37.) Which of the following is false about main method ?

a) It should be declared public and static


b) It should have only 1 argument of type String array
c) We can override main method
d) We can overload main method

38.) Java functional interface can be defined as ---------

a) Simple Abstract Markup


b) Simple Active Markup
c) Single Ambivalue Method
d) single abstract method

39.)Pick the right statement about creating a custom Java annotation.

a) Annotations are created by using @interface, followed by annotation name.


b) Annotation can have elements as well. They look like methods. We should not
provide implementation for these elements.
c) All annotations extends java.lang.annotation. Annotation interface. Annotations
cannot include any extends clause.
d) All of the above

40.) What is the command line tool introduced for JS engine in Java8?

a) jjs
b) jss
c) jfs
d) jbd
41.) Which one of the following statements on Java String is correct?

a) replace() method replaces only first occurrences of a character in invoking string with the
given character.
b) replace() method replaces last occurrence of a character in invoking string with the given
character.
c) replace() method replaces all occurrences of one character in invoking string with the
given character.
d) replace() method replaces all the characters in invoking string with the given character.

42.) In Java, which of the following can be marked static?


a) Methods, Variables, Initialization Blocks, Outer Classes, and Nested Classes
b) Methods, Variables, Initialization Blocks, and Nested Classes
c) Methods, Variables, Initialization Blocks, and Outer Classes
d) Methods, Variables, and Initialization Blocks

43.) In Java, which of these class types supports sequential and parallel processing of
data?
Queue
Lambda
ExecutorService
Streams

44.) Which of the following terminologies are typically used with regards to AOP?

A. Concerns
B. Advice
C. Float
D. Pointcut

a) A, B, and D
b) A, C, and D
c) A, B, and C
d) B, C, and D

45.) What is the use of Autodiscovery?

a) Eliminate the use of the <Property> element


b) Reduce the use of the <Constructor-arg> element
c) Eliminate the use of the <Props> element
d) Reduce the use of the <bean> element
46.) The -------- packages are the basis of spring Framework’s IOC container

a) org.springframework.beans and org.springframework.Application


b) org.springframework.properties and org.springframework.context
c) org.springframework.beans and org.springframework.properties
d) org.springframework.beans and org.springframework.context

47.) Which of the following attributes are valid in a Spring bean definition?

A. ID
B. Map
C. Set
D. Class

a) A and C
b) A and D
c) B and C
d) C and D

48.) What Spring Collection can be used to inject a collection of name-value pairs, where
name and value can be of any type?

a) <set>
b) <List>
c) <map>
d) <props>

49.) Which attributes are applicable for an inner bean?

a) Context,Parent
b) Id,Class
c) Class,Inner
d) Interface,Id

50.) To use bean definition template, you should add what attribute in the bean?

a) abstract="true"
b) interface="true"
c) class ="com.example.helloworld"
d) public ="true"
51.) Which bean scopes are valid only in the context of a web-aware Spring Application
Context?

a) Singleton & Prototype


b) Session, Globalsession & Request
c) Singleton, Prototype, Request & Session
d) Session, Singleton & GlobalSession

52.) A collection value of the type java.util.Properties is defined by what element?

a) <props>
b) <prop>
c) <properties>
d) <property>

53.) Which of the following is an annotation for Spring Java-based configuration?

a) @Component
b) @SpringConfiguration
c) @SpringXml
d) @Configuration

54.) What does the JDBC Template uses to connect to the database?

a) A simple java bean with connection properties


b) A data source bean configuration
c) An XML with DB connection parameters
d) A jdbc connection object

55.) Which of the following tasks are performed by a JDBCTemplate?

A. Execute SQL query.


B. Execute Update statements.
C. Execute a Java program.
D. Execute stored procedure calls.

a) A, B and D
b) A, B and C
c) A, C and D
d) B, C and D
56.) Does Spring provide programmatic transaction management?
a) Yes, with the TransactionTemplate class
b) Yes, with the TransactionService class
c) Yes, using the @Transactional bean post processor
d) No, Spring does not provide transactional management

57.) Which of the following are MVC – Specific annotations:

I. @Controller
II. @RequestMapping
III. @PathVariable
IV. @Autowired

a) I and II only
b) I, II and III only
c) I, III and IV only
d) II and IV only

58.) In the following example, what type of autowire will be used?


@Autowired(required=false)
Public Employee AutowiredByConstructorService(@Qualifier("employee")Employee
emp){
this.employee=emp;
}

a) ByName
b) ById
c) @Autowired
d) Constructor

59.) What annotation wiring element is added to scan packages to find and register
Beans within the Application Context?

a) <context:annotation-config/>
b) <context:annotation-scan/>
c) <context:component-config/>
d) <context:component-scan>

60.) To annotate all your Data Access Object (DAO) classes, use the --------

a) @Service
b) @Classes
c) @Repository
d) @Component

You might also like