0% found this document useful (0 votes)
22 views8 pages

Tina Questions

This document contains 31 multiple choice questions related to Java programming concepts. The questions cover topics like JSTL, prepared statements, design patterns, annotations, servlets, JUnit testing, and Spring framework.

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 PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
22 views8 pages

Tina Questions

This document contains 31 multiple choice questions related to Java programming concepts. The questions cover topics like JSTL, prepared statements, design patterns, annotations, servlets, JUnit testing, and Spring framework.

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 PDF, TXT or read online on Scribd
You are on page 1/ 8

1.What gets printed when the following JSTL code fragment is executed?

<%@tagliburi="http://java.sun.com/jsp/jstl/core"prefix="c"%> ${item}
1.0,3,6,9,12
2.3,6,9,12
3.0,6,9,12
4.0,3,6,9
Answer-1

2.Fill in the blank. This is an example of preparedstatement interface


that_______________
PreparedStatementstmt=con.prepareStatement("select*from emp");
ResultSetrs=stmt.executeQuery();
while(rs.next()){ System.out.println(rs.getInt(1)+""+rs.getString(2)); }
1.Deletestherecord
2.Retrievestherecord
3.Updatestherecord
4.Insertstherecord
Answer-2

3. In a component diagram, how would you indicate a dependency?


1.A solid line between the two.
2.A dashed arrow between the two.
3.A solid bi-directional arrow between the two.
4.A circle containing the two.
Answer-2

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

5. When using the to reference a Java Bean for use within a JSP, the id attribute
defines_______________.
1.The class name of the JavaBean
2.The package name of the JavaBean
3.The instance name of the JavaBean
4.Defines nothing as there is no id attirbute
Answer-3

6. Which of the following are correct with filter?


1.Modifies request/response
2.Used for logging/auditing
3.Security checks
4.All of the above
Answer-4

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


1.Methods,Variables,InitializationBlocks,OuterClasses,andNestedClasses
2.Methods,Variables,InitializationBlocks,andNestedClasses
3.Methods,Variables,InitializationBlocks,andOuterClasses
4.Methods,Variables,andInitializationBlocks
Correct-2

8. Pick the right statement about creating a custom Java annotation.


1.Annotations are created by using @interface, followed by annotation name.
2.An annotation can have elements as well. They look like methods. We should not
provide implementation for these elements.
3.All annotations extends java.lang.annotation. Annotation interface. Annotations
can not include any extends clause.
4.All of the above
Correct-4

9. In Java9, private methods are allowed in Interfaces.


1.True
2.False
Answer- 1

10. Java system properties can be set or modified at runtime.


1.True
2.False
Answer-True

11. Identify the Java class used to create a new Process.


1.ProcessBuilder
2.ProcessFactory
3.Process
4.Thread
Answer-1

12. Pick the correct Java method reference usages.


1.object::instance Method
2.Class::static Method
3.Class::new
4.All of the above
Answer-4
13. Which of the following examples summarizes Program to an interface rather
than an implementation?
1.Map m=newHashMap();
2.ArrayList list=newArrayList();
3.ArrayList<Integer>=newArrayList<Integer>();
4.String s="HelloWorld";
Answer-3

14. To use java.util.List, what is the Spring Collections element that you need?
1.<list>
2. <List>
3.<lists>
4.<util:list>

15. Which annotation can be used in order to specify a method as transactional?


1.@Service
2.@Component
3.@Transactional
4.@Scope
Answer-3
16. Which one of the following is one of the challenges of Traditional Transaction
Management?
1.Transaction Management at Database ConnectionLevel
2.Programmatic Management of transactions
3.Error-proneConnection Management
4.Alloftheabove
Correct-4

17. Fill in the blank. The___________package contains classes that help in


connecting to a database, sending SQL statements to the database, and processing
the query results. 1.connection.sql
2.db.sql
3.pkg.sql
4.java.sql
Correct-4

18. 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 SQL Exception that is thrown by the method that
executes the statement.
2.You must catch the unchecked SQLWarningException 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 ResultSet object about possible warnings generated by the
database.
Correct-3

19. How to initialize a servlet?


1.By using constructor
2.By using init
3.All of the above
4.None of the above
Correct-2
20. Which is used to separate multiple attributes in get method?
1.&
2.,
3.+
4.?
Answer-1

21. If we run the test suite as JUnitTest, what will be the order of execution of all the
four test classes?
@RunWith(Suite.class)
@SuiteClasses({
AnnotationsTests.class,
AssertTests.class,
CalculateTest.class,
EmployeeTest.class })
1.1)AnnotationsTests 2)CalculateTest 3)EmployeeTest 4)AssertTests
2.1)AnnotationsTests 2)AssertTests 3)CalculateTest 4)EmployeeTest
3.1)AnnotationsTests 2)CalculateTest 3)AssertTests 4)EmployeeTest
4.1)EmployeeTest 2)CalculateTest 3)AssertTests 4)AnnotationsTests
Correct-2

22. Pick the class that is NOT part of Java collection framework.
1.Map
2.List
3.Queue
4.Struct
Correct-4

23. Java Functional Interface can be defined as_____.


1.Simple Abstract Markup
2.Simple Active Markup
3.Single Ambivalue Method
4.Single Abstract Method
Correct-4
24. You can only use a servlet if it is installed on _____________
1.Internet
2.Client
3.Server
4.Browser

25. What is the effect of executing the following JSP statement , assuming a class
with name Employee exists in classes package?

%@page import = “classes.Employee”%


<jsp:useBean id = “employee”class=”classes.Employee “scope=”session”/>
<jsp:setProperty name=”employee” property=”*”/>

1.The code does not compile as there is no property attribute of setProperty tag.
2.The code does not compile as the property attribute cannot take * as a value
3.The code sets value of all properties of employee bean to “*”.
4.The code sets the values of all properties of employee bean matching parameters
in request object

26. 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.TestA,testB
2.testBtestA
3.testA compile error
4.testB compile error

27. Which one of these statements about XML declaration of transaction manager
bean is NOT true?
a) The tx namespace provides JTA transaction manager declaration shortcut syntax.
b) The Id of the bean has to be transactionManager.
c) Depending on the application persistence technology, the
HibernateTransactionManager or the DataSourceTranasctionManager could be used
as bean class.
d) A default transaction timeout could be given.

28. 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-}

29. 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
30. 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

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

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy