0% found this document useful (0 votes)
60 views10 pages

Assessment

The document contains questions about Java, design patterns, JDBC, JSP, JSTL, JUnit testing, servlets, Spring and UML fundamentals. It asks about core Java concepts like the main method, method overriding and overloading. Design pattern questions cover Iterator, Bridge and Factory patterns. Questions also cover Spring concepts such as dependency injection, transactions and Java configuration.

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)
60 views10 pages

Assessment

The document contains questions about Java, design patterns, JDBC, JSP, JSTL, JUnit testing, servlets, Spring and UML fundamentals. It asks about core Java concepts like the main method, method overriding and overloading. Design pattern questions cover Iterator, Bridge and Factory patterns. Questions also cover Spring concepts such as dependency injection, transactions and Java configuration.

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/ 10

Core Java

1. Which of the following statements is false about Java main method?

1.We can override main method.

2.Main method should be declared public and static.

3.Main method should have only 1 argument of type String array.

4.We can overload main method.

Answer-1

2. Which of the following is the immutable Java List static factory method?

1.List.of

2.List.immutable

3.List.create

Answer-1

3. Pick the correct Java method reference usages.

1.object::instanceMethod

2.Class::staticMethod

3.Class::new

4.Alloftheabove

Answer-4

4. Which is the correct Java code snippet to be used to create a Functional Interface?

1.interfaceMyFunctionalInterfaceimplementsFunctional{

2."@FunctionalInterface interface MyFunctionalInterface{"

3."@FunctionalinterfaceMyFunctionalInterface{

Answer-2

5. Which of these OOPS concept is enabled by method overriding in Java?

1.Polymorphism

2.Abstraction

3.Inheritance

4.Encapsulation
Answer-1

6.How does one assign system property values to variable using Java class fields?

1."@Autowire("${aProperty}")private String aSysProp;"

2."@Environment("${aProperty}")private String aSysProp;"

3."@Property("${aProperty}")private String aSysProp;"

4."@Value("${aProperty}")private String aSysProp

Answer-4

7.Which of these OOPS concept is enabled by method overriding and method overloading in Java?

1.Polymorphism

2.Abstraction

3.Inheritance

4.Encapsulation

Answer-1

Design Patterns
1. You need to provide away to access the elements of an aggregate object sequentially, without
exposing the underlying representation. Which design pattern should you apply?

1.Builder

2.Iterator

3.Observer

4.Command

Answer-2

2. Which design pattern would you use to decouple an abstraction from its implementation so that
the two can vary independently?

1.Singleton

2.Bridge

3.Adaptor

4.Factory

Answer-2
3. Which Collections elements does Spring support?

1.List,hashmap,arraylist,andset

2.List,props,hashmaps,andarraylist

3.List,set,map,andprops

4.Hashmaps,arraylist,list,andtreemap

Answer-3

JDBC Basic Concepts

1. Which of the following is correct about DriverManager.registerDriver()method call?

1.This method is used to register the database driver.

2.This static method is used in case you are using a non-JDK compliant JVM, such as the one
provided by Microsoft.

3.All of the above

4.None of the above

Answer-All of the above

2. In the snippet below, what line of code needs to be added to move the cursor to the
3rdrowintheresultset? Class.forName("oracle.jdbc.driver.OracleDriver"); Connection
con=DriverManager.getConnection("jdbc:oracle:thin:@localhost:1521:xe","system","or acle");
Statement stmt=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_
UPDATABLE); ResultSetrs=stmt.executeQuery("select*fromemp765");

1.rs.move(3);

2.rs.next(3)

3.rs.absolute(3);

4.rs.getString(3);

Answer-3

3.How do you know in your Java program that an SQL warning is generated as a result of executing
an SQL statement in the database?

1.You must catch the checked SQLException that is thrown by the method that executes the
statement.
2.You must catch the unchecked SQLWarning Exception that is thrown by the method that
executes the statement.

3.You must invoke the getWarnings() method on the Statement object(or a sub interface there
of).

4.You must query the Result Set object about possible warnings generated by the database.

Correct-3

JSP Actions

1. When using the to reference a Java Bean for use within a JSP, the id attribute
defines_______________.

1.The class name of the Java Bean

2.The package name of the Java Bean

3.The instance name of the JavaBean

4.Defines nothing as there is no id attirbute

Answer-3

Introduction JSTL
Junit Testing
1.Which of the following annotations causes that method run once before any of the test methods in
the class?

1.@Test

2.@Before

3.@BeforeClass

4.@AfterClass

Answer-3

What is the output of following code?

Public class NameRuleTest {


@Rule
Public TestName name = new TestName();
@Test
Public void testA() {
System.out.println(name.getMethodName());
assertEquals(“testA”, name .getMethodName());
}

@Test
Public void testB() {
System.out.println(name.getMethodName());
assertEquals(“testB”,name.getMethodName());
}
}

1.TestATestB
2.testBtestA
3.testA compile error
4.testB compile error
Answer-1

Servlet Filters

Servlet Listeners
1. Which type of listener and listener method can be used to call close() when each of the
application's users is finished with the connection?

1.HttpSessionListener and its sessionDestroyed method

2.ServletAttributeListener and its attributeRemoved method

3.ServletRequestListener and the requestDestroyed method

4.RequestDispatcherListener and its forwardInitiated method

Correct-1
2. Which of the following are correct with filter?

1.Modifies request/response

2.Usedforlogging/auditing

3.Securitychecks

4.Alloftheabove

Answer-4

Servlet Basics
1. Identify the correct servlet lifecycle.

1.servletloading,servletinstance,init,service,anddestroy

2.init,servletloading,servletinstance,service,anddestroy

3.init,servletinstance,servletloading,service,anddestroy

4.init,service,destroy,servletinstance,andservletloading

2. What gets printed when the following is compiled?

<% int y=0;>

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

<% z++;++y%>

<%}%>

<% if(z<y) {%>

<%=z%>

<%}else{%>

<%=z-1%>

<%}%>

1.0

2.1

3.2 ---Answer

4.3

Spring AOP
Spring Auto wiring
What is the use of Autodiscovery and Autowiring?

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

1. What attribute is added in the bean.xml to reduce or eliminate the need of and?

1.Autodiscovery

2.Autowire

3.Scope

4.Auto-detect

Answer-2

Spring Dependency, Inner Beans and Scope


Spring JDBC
1.Which annotation can be used in order to specify a method as transactional?

1.@Service

2.@Component

3.@Transactional

4.@Scope

Answer-3

2. Which one of the following is one of the challenges of Traditional Transaction Management?
1.Transaction Management at Database Connection Level

2.Programmatic Management of transactions

3.Error-prone Connection Management

4.Alloftheabove

Correct-4

3. The Dependency Look up is a methodology where we get there source after demand. There can be
various ways to get the resource. Types of Dependency Look up include:

1.FactoryMethod

2.JNDIMethod

3.KeyWordMethod
4.Alloftheabove

Correct-4

Spring Java Configuration

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

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

Spring ORM and MVC


Stereotype Annotations
1.In the following example, what type of autowire will be used?

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

1.ByName

2.ById

3.@Autowired

4.Constructor

Answer-4

UML Fundamentals
1. You are creating a class diagram using UML and you need to show that one of your classes is an
abstract class. How would you do that?

1.Underline the name of the class in the diagram.

2.Draw a dotted line between it and the other classes.

3.Use italics for the name of the class.

4.Draw an arrow with a hollow diamond head between it and the other classes.

Answer-3

2.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.
Answer-3

Web Application Basics

1. When using HTML forms, which of the following is true for POST method?

1.POST allows users to book mark URLs with parameters.

2.The POST method should not be used when large amount of data needs to be transferred.

3.POST allows secure data transmission over the http method.

4.POST method sends data in the body of the request.

Answer-4

2. A user types the URL in a browser: http://www.javatraining.com/GH/index.html.Which HTTP


request gets generated?

1.GETmethod

2.POSTmethod

3.HEADmethod

4.PUTmethod

Answer-1

3.Which is used to separate multiple attributes in get method?

1.&

2.,

3.+

4. ?

Answer-1

Don’t know the topic name


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.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"

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

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

You might also like