Sodapdf
Sodapdf
ans -1
ans- 3
15)Consider the following JDBC code snippet and identify the threat that it projects
1 Statement s c.createStatement();
2 String str="select * from student WHERE id=";
3//input the id from user
4 ResultSet rs-s.executeQuery(str+String.valueOf(input));
options:-
a)Security misconfiguration
c)OSOL injection
ans - b
13)As per the concepts of Java Spring, which of the following can be used to load a standalone applicatio
n in Spring?
a)FileSystemXmlApplicationContext.
b)ClassPathXmiApplicationContext
c)GenericXmlApplicationContext
d)ResourceApplicationContext
e)SimpleBeanFactory
ans - a,b,c
String y = "test";
System.out.println(x==y);
System.out.println(x.equals(y));
}
}
a)True
False
b)True
c)False
True
d)False
False
ans - c
class abc{
int a, b;
System.out.println("a="+ a);
ans - line 1.
6)In which of the following classes, elements can be retrieved using their index?
ArrayList class
LinkedList class
HashSet class
TreeSet class
1)A and C
2)A, B and C
3)A and B
4)B and C
ans - may be A
Automatically
Manually
ans - Automatically
one
Two
Three
None
ans - two
13)Consider a table named SCHOOL In the Oracle database with the following data:
3 102 Smith 52
4 103 Mark 35
5 104 Harry 83
This class is mapped with the School table in the Configuration file.
What will be the output when the client application runs the following HQL query using the Session object
s?
Query query=s.createQuery(q);
List 1-query.list();
Iterator 1-1.iterator();
while(1.hasNext()) {
System.out.println(i.next());
}
import java.util.*;
public class JavaEleven {
try{
System.out.println("3"); input.forEach(System.out::println);
System.out.println("-3");
ans -
3
-2
-1
0
1
2
-3
System.out.println(1);
A. Public
B. Final
C. Static
D. Abstract
ans - A,C,D
ans - 16
22)Which of the following statements about bean naming is false in Java Spring?
2 OR
ans - c
7)Which of the following data types is a 16-bit signed two’s complement integer?
a)Int
b)Byte
c)Short
d)Float
ans - c
28)Which of the given statements about the following methods in a class is true?
c)The two methods are neither overloaded nor overridden, and there with be a complete time error.
d)The two methods are neither overloaded nor overridden and the code will complie successfully.
ans - c
a)New operator
B)Class forName("name")
Only A
Only B
Both A and B
ans - only A
Only A
A and C
A and D
C and D
ans - c and d
25)class Parent {
c)Runtime exception
ans - a
yyyy-MM-dd
MM-dd-YY
Oyy-mm-dd
dd-mm-yyyy
ans - yyyy-MM-dd
18)Consider two Persistent class Employee and Department mapped with two tables in the
database
options:-
inner join
cross join
17)Which of the following data types is a 64-bit signed two’s complement integer?
Int
Long
Float
Byte
ans - Long
10)As per Java serviets concepts, which of the following methods will you use to send a response in the f
orm of character cata to the client
HttpServletRequest getWriter()
HttpServerResponse getCharacterWrmer)
HttpServetRequest getOutputStream()
HttpServletResponse getWriter)
16)output of code?
class ExtendedString extends string{
public static void main(String []s){
ExtendedString esl = "hello", es2= "world";
System.out.println (est + es2);
}
}
hello world
Compiler error ExtendedString cannot inherit from final java lang string
hello+ world
ans - Compiler error ExtendedString cannot inherit from final java lang string
The values in fields with the Volatile modifier will not survive serialization an de-serialization
8)Which of the following is the correct parent used for creating spring-boot application with maven?
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>{spring-boot-version}</version>
</parent>
remember:-
.boot
spring-boot-starter-parent
By using BeanFactory.
By using ApplicationContext.
ans-all
3)class q35{
int i =2;
if(i==0){
break;
else{
System.out.println("Else");
}
}
}
ans - Else
4)if the onMessage method of a message-driven bean encounters an application exception in EJB, what
would be your next step?
Only B
Both A and B
Neither A nor B
ans - only B
11)As per la serviete concepts, which of the following Interfaces provides access to the method, getRequ
estedSessionid()?
HttpSession
HttpServletRequest
HttpServletResponse
ServletContext
ans - HttpServletRequest
System.out.println("\nBike is " + "in gear" + this.gear + "with a cadence of " + this.cadence + " and travelli
ng at a speed of" + this.speed + ". ");
}
Inheritance
Polymorphism
Constructor
Destructor
ans - constructor
18)Given below is a spring boot code using get mapping that annotates two methods to determine the na
me and number of a user.
What is the significance of the URL Path based on the mentioned code?
@GetMapping("/root/name")
public String name()
{
return "abc";
}
@GetMapping("/(no)")
public String getNo (@PathVariable String no)
{
return "fetching userno";
options:-
d)each annotation of @getmapping will specify root path of URL and then differ to different paths
ans - a
int[] anArray {
};
9)Which of the following methods would you use to make function calls in Java?
Call by value
Call by reference
Rumtime error
Compile successfully
2)
ans -
MIKE
SMITH
30)Which of the following options cannot directly cause a thread to stop executing in Java?
29)Which class is the root(apex) of the entire exception handling class hierarchy?
Throwable class
Exception class
Error class
RuntimeException class
25)You have a requirement for a collection that allows to search for values using keys (Le like a dictionary
) and also want this collection to maintain insertion order. Which of the following options will you use?
HashMap
LinkedHashMap
TreeMap
SortedMap
ans - LinkedHashMap
A. New operator
B. Class.forName("name")
Only A
Only B
Both A and B
ans - Only A
21)Which of the following commands complies a Java program in which the class is defined as "Hello"?
Compile Hello.java
Javac Hello.java