0% found this document useful (0 votes)
47 views15 pages

Report Practice2 PRA MCQ Java

Sreejit Guha Thakurta took the Practice2_PRA_MCQ_Java test on March 12, 2024, scoring 83.3% with 25 out of 30 questions correct in 39 minutes and 7 seconds. The test covered topics such as Exception Handling, Method Overloading, and JDBC, with specific scores in JDBC (10/10), Java (9/10), and Java Web (6/10). There were no comments from the recruiter or team regarding the performance.

Uploaded by

rtandon3102
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)
47 views15 pages

Report Practice2 PRA MCQ Java

Sreejit Guha Thakurta took the Practice2_PRA_MCQ_Java test on March 12, 2024, scoring 83.3% with 25 out of 30 questions correct in 39 minutes and 7 seconds. The test covered topics such as Exception Handling, Method Overloading, and JDBC, with specific scores in JDBC (10/10), Java (9/10), and Java Web (6/10). There were no comments from the recruiter or team regarding the performance.

Uploaded by

rtandon3102
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/ 15

Practice2_PRA_MCQ_Java_1st_Feb_24_KOL  4837474_857_25872644@tcsltd.

com

You can view this report online at : https://www.hackerrank.com/x/tests/1852902/candidates/61472214/report

Full Name: Sreejit Guha Thakurta

Email: [email protected] scored in


83.3% Practice2_PRA_MCQ_Java_1st_Feb_24_K
Test Name: Practice2_PRA_MCQ_Java_1st_Feb_24_KOL
in 39 min 7 sec on 12 Mar 2024 14:51:45 IST
Taken On: 12 Mar 2024 14:51:45 IST
25/30

Time Taken: 39 min 7 sec/ 40 min

EmployeeID: 2589920

Invited by: Velantish

Invited on: 12 Mar 2024 14:51:00 IST

Skills Score:

Tags Score: JDBC 10/10

Java 9/10

Java_Web 6/10

Recruiter/Team Comments:

No Comments.

Question Description Time Taken Score Status

Q1 Adv_Java_1 : Exception Handling  Multiple Choice 3 min 1/ 1 


Q2 Adv_Java_2 : Exception Handling  Multiple Choice 21 sec 1/ 1 
Q3 Adv_Java_3 : Method Overloading  Multiple Choice 3 min 18 sec 1/ 1 
Q4 Adv_Java_4  Multiple Choice 2 min 40 sec 1/ 1 
Q5 Adv_Java_5  Multiple Choice 53 sec 1/ 1 
Q6 Adv_Java_6  Multiple Choice 39 sec 0/ 1 
Q7 Adv_Java_7  Multiple Choice 31 sec 1/ 1 
Q8 Adv_Java_8  Multiple Choice 1 min 30 sec 1/ 1 
Q9 Adv_Java_9  Multiple Choice 1 min 50 sec 1/ 1 
Q10 Adv_Java_10  Multiple Choice 1 min 41 sec 1/ 1 
Q11 Java_JDBC_1  Multiple Choice 1 min 16 sec 1/ 1 
Q12 Java_JDBC_2  Multiple Choice 1 min 43 sec 1/ 1 
Q13 Java_JDBC_3  Multiple Choice 11 sec 1/ 1 

1/15
Q14 Java_JDBC_4  Multiple Choice 57 sec 1/ 1 
Q15 Java_JDBC_5  Multiple Choice 14 sec 1/ 1 
Q16 Java_JDBC_6  Multiple Choice 11 sec 1/ 1 
Q17 Java_JDBC_7  Multiple Choice 29 sec 1/ 1 
Q18 Java_JDBC_8  Multiple Choice 2 min 12 sec 1/ 1 
Q19 Java_JDBC_9  Multiple Choice 2 min 20 sec 1/ 1 
Q20 Java_JDBC_10  Multiple Choice 47 sec 1/ 1 
Q21 Java_Web_1  Multiple Choice 51 sec 0/ 1 
Q22 Java_Web_2  Multiple Choice 48 sec 1/ 1 
Q23 Java_Web_3  Multiple Choice 1 min 55 sec 0/ 1 
Q24 Java_Web_4  Multiple Choice 6 sec 0/ 1 
Q25 Java_Web_5  Multiple Choice 1 min 8 sec 1/ 1 
Q26 Java_Web_6  Multiple Choice 7 sec 1/ 1 
Q27 Java_Web_7  Multiple Choice 32 sec 1/ 1 
Q28 Java_Web_8  Multiple Choice 1 min 22 sec 1/ 1 
Q29 Java_Web_9  Multiple Choice 3 min 22 sec 1/ 1 
Q30 Java_Web_10  Multiple Choice 2 min 4 sec 0/ 1 

QUESTION 1 Adv_Java_1 : Exception Handling 



Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

What will be the output for following code ?


Score 1

class DemoClass
{
static void test() throws RuntimeException
{
throw new ArithmeticException();
}
public static void main (String args[])
{
try{
test();
}
catch (RuntimeException re)
{
System.out.println("Exception Handled");
}
}
}

2/15
CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

RuntimeException

CompilationError

ExceptionHandled

None of the above

No Comments

QUESTION 2 Adv_Java_2 : Exception Handling 



Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

Which method is used to obtain the textual description of an exception in Java?


Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

getMessage()

printStackTrace()

toString()

getDescription()

No Comments

QUESTION 3 Adv_Java_3 : Method Overloading 



Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

Score 1
Jane is trying to run the following code on method overloading , she is
confused while executing the code that the statement 1 she has
written calls which method . Help jane to understand the concept by
choosing correct option

class MethodOverloading{
void display(int a,float b) { // Method
1
System.out.println(a+b);
}
void display(int a,int b) { //
Method 2
System.out.println(a+b);
}
void display(int a,long b) { // Method 3
System.out.println(a+b);
}
void display(int a,double b) {
System.out.println(a+b); // Method 4
}
}
public class DemoClass{
public static void main(String[] args) {
MethodOverloading mo=new MethodOverloading();

3/15
mo.display(10, 10.5); //
Statement 1
}
}

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

Method 1

Method 2

Method 3

Method 4

No Comments

QUESTION 4 Adv_Java_4 

Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

what will be the output of following code after Execution ?


Score 1
class Animal {
void makeSound() {
System.out.println("Animal makes a sound");
}
}
class Lion extends Animal {
void makeSound() {
System.out.println("Lion roars");
}
}
class Dog extends Animal {
void makeSound() {
System.out.println("Dog Barks");
}
}
public class DemoClass{
public static void main(String[] args) {
Animal animal1 = new Lion();
Animal animal2 = new Dog();
animal1.makeSound();
animal2.makeSound();
}
}

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

Lion roars
Dog Barks

Dog Barks
Lion roars

Animal makes a sound


Lion roars
Dog Barks

4/15
Lion roars
Dog Barks
Animal makes a sound

No Comments

QUESTION 5 Adv_Java_5 

Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

Score 1
what will be the output of following code after execution ?
class DemoClass{
public static void main(String[] args) {
Stack<Integer> stk= new Stack<>();
stk.push(1000);
stk.pop();
stk.push(2000);
stk.push(3000);
stk.pop();
stk.push(4000);
System.out.println(stk.size());
}
}

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

No Comments

QUESTION 6 Adv_Java_6 

Multiple Choice Java

Wrong Answer
QUESTION DESCRIPTION

Score 0
Sameer is trying to execute following code . what will be the output after
execution ?
public class DemoClass{
public static void main(String[] args) {
ArrayList list=new ArrayList();
list.add("Chennai");
list.add("Mumbai");
list.add("Kolkata");
list.add("Bangalore");
int a=(int)list.get(0);
System.out.println(list);
}
}

5/15
CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

ArrayIndexOutOfBoundException

ClassCastException

InputMismatchException

[Chennai, Mumbai, Kolkata, Bangalore]

No Comments

QUESTION 7 Adv_Java_7 

Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

Score 1
what will be the output of following code after execution ?
class DemoClass{
public static void main(String[] args) {
Stack<Integer> stk= new Stack<>();
stk.push(1000);
stk.pop();
stk.push(2000);
stk.push(3000);
stk.pop();
stk.push(4000);
System.out.println(stk.size());
}
}

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

No Comments

QUESTION 8 Adv_Java_8 

Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

Score 1
Sameer is trying to execute following code . what will be the output after
execution ?
public class DemoClass{
public static void main(String[] args) {
ArrayList list=new ArrayList();
list.add("Chennai");
list.add("Mumbai");
list.add("Kolkata");
list.add("Bangalore");
int a=(int)list.get(0);
6/15
System.out.println(list);
}
}

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

ArrayIndexOutOfBoundException

ClassCastException

InputMismatchException

[Chennai, Mumbai, Kolkata, Bangalore]

No Comments

QUESTION 9 Adv_Java_9 

Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

Score 1
what will be the output of following code after execution ?
public class LinkedListCollection {
public static void main(String args[]) {

LinkedList<String> ll = new LinkedList<String>();


ll.add("Google");
ll.add("TCS");
ll.add("Meta");
ll.add("Microsoft");
LinkedList<String> ll2 = new LinkedList<String>();
ll2.add("Twitter");
ll2.add("Tencent");
ll2.addAll(ll);
System.out.println(ll2);

}
}

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

[Google, TCS, Meta, Microsoft, Twitter, Tencent]

[Twitter, Tencent, Google, TCS, Meta, Microsoft]

[Google, Meta, Microsoft, TCS, Tencent, Twitter]

[Twitter, Tencent, TCS, Microsoft, Meta, Google]

No Comments

QUESTION 10 Adv_Java_10 

Multiple Choice Java

Correct Answer
QUESTION DESCRIPTION

Which of the following is a runtime exception on java ?


Score 1

7/15
CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

NullPointerException

FileNotFoundException

ClassNotFoundException

IOException

No Comments

QUESTION 11 Java_JDBC_1 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

Score 1
Which method is used to retrieve the auto-generated keys after executing
an INSERT statement in JDBC ?

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

executeUpdate()

executeQuery()

getGeneratedKeys()

getResultSet()

No Comments

QUESTION 12 Java_JDBC_2 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

Which JDBC interface is used to execute a parameterized SQL query to retrieve data from a database?
Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

Statement

ResultSet

PreparedStatement

CallableStatement

No Comments

QUESTION 13 Java_JDBC_3  Multiple Choice JDBC

8/15

Correct Answer
QUESTION DESCRIPTION

Which of these obtains a Connection?


Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

Connection.getConnection(url)

Driver.getConnection(url)

DriverManager.getConnection(url)

new Connection(url)

No Comments

QUESTION 14 Java_JDBC_4 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

Jay is trying to connect with database. help jay by selecting correct method to connect with Database ?
Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

connect( )

openConnection( )

getConnection( )

createConnection( )

No Comments

QUESTION 15 Java_JDBC_5 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

What is the purpose of the 'ResultSet' interface in JDBC ?


Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

It represents a precompile SQL statement

It provides method for executing SQL queries

It handles database operations

It respresents the resultset of database Query

No Comments

QUESTION 16

9/15

Correct Answer
Java_JDBC_6  Multiple Choice JDBC

QUESTION DESCRIPTION
Score 1
Rahul is trying to end the database connection. help rahul to end the database connection by using proper
method

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

shutdown()

close()

endconnection()

disconnect()

No Comments

QUESTION 17 Java_JDBC_7 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

Ram is learning about a JDBC. help ram to understand the Steps


Score 1
of connecting with Database by choosing correct option

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

1. Register the driver class

2. Creating connection

3. Creating statements

4. Executing queries

5. Closing connection

1. Register the driver class

2. Creating connection

3. Executing queries

4. Creating statements

5. Closing connection

1. Register the driver class

2. Creating connection

3. Closing connection

4. Creating statements

5. Executing queries

10/15
1. Register the driver class

2. Creating connection

3. Creating statements

4. Closing connection

5. Executing queries

No Comments

QUESTION 18 Java_JDBC_8 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

in JDBC which exception is thrown when there is an error in database


Score 1
connectivity such as a failed connection or authentication ?

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

SQLException

DatabaseException

ConnectionException

ConnectivityException

No Comments

QUESTION 19 Java_JDBC_9 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

Hritik is trying to establish the connection with the Apche derby database.
Score 1
Help Hritik to choose correct code snippet

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

Class.forName("org.mysql.jdbc.EmbeddedDriver");

con=DriverManager.getConnection("jdbc:derby:C:\\User\\MyDB;create=true");

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

con=DriverManager.getConnection("jdbc:derby:C:\\User\\MyDB;create=true");

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

con=DriverManager.getConnection("derby:C:\\User\\MyDB;create=true");

Class.forName("org.apache.derby.jdbc.EmbeddedDriver");

con=DriverManager.getConnection("jdbc:C:\\User\\MyDB;create=true");

11/15
No Comments

QUESTION 20 Java_JDBC_10 

Multiple Choice JDBC

Correct Answer
QUESTION DESCRIPTION

Which of the following statements about the PreparedStatement interface in JDBC is True ?
Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

It is used for executing parameterised SQL Query

it is used for executing stored procedure

it is used to execute batch updates

it is an alternative for Statement interface

No Comments

QUESTION 21 Java_Web_1 

Multiple Choice Java_Web

Wrong Answer
QUESTION DESCRIPTION

Which of the following is true about HTTP Get method?


Score 0

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

The GET method sends the encoded user information appended to the
page request.

The GET method is the defualt method to pass information from browser
to web server.

Both the above

None of the above

No Comments

QUESTION 22 Java_Web_2 

Multiple Choice Java_Web

Correct Answer
QUESTION DESCRIPTION

Which of the following code is used to get a HTTP Session object in servlets?
Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

request.getSession()

response.getSession();

12/15
new Session()

None of the above

No Comments

QUESTION 23 Java_Web_3 

Multiple Choice Java_Web

Wrong Answer
QUESTION DESCRIPTION

Which statement about jspInit() is true?


Score 0

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

It does not have access to ServletConfig.

It does not have access to ServletContext.

It is called only once.

It cannot be overridden.

No Comments

QUESTION 24 Java_Web_4 

Multiple Choice Java_Web

Wrong Answer
QUESTION DESCRIPTION

What will be the output for the following code?


Score 0
<html><body>
<% int i = 20 ;%>
<% while(i>=15) { %>
out.print(i);
<% } %>
</body></html>

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

2.02E+11

20

15

None of the above

No Comments

QUESTION 25 Java_Web_5 

Multiple Choice Java_Web

Correct Answer
QUESTION DESCRIPTION

Which of the following code is used to get an attribute in a HTTP Session object in servlets?
Score 1

13/15
CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

session.getAttribute(String name)

session.alterAttribute(String name)

session.updateAttribute(String name)

session.setAttribute(String name)

No Comments

QUESTION 26 Java_Web_6 

Multiple Choice Java_Web

Correct Answer
QUESTION DESCRIPTION

Which of the following is stored at client side?


Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

URL rewriting

Hidden form fields

SSL sessions

Cookies

No Comments

QUESTION 27 Java_Web_7 

Multiple Choice Java_Web

Correct Answer
QUESTION DESCRIPTION

What temporarily redirects response to the browser?


Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

<jsp:forward>

<%@directive%>

response.sendRedirect(URL)

response.setRedirect(URL)

No Comments

QUESTION 28 Java_Web_8 

Multiple Choice Java_Web

Correct Answer
QUESTION DESCRIPTION

Which of the following is not a directive in JSP?


Score 1
14/15
Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

page directive

include directive

taglib directive

command directive

No Comments

QUESTION 29 Java_Web_9 

Multiple Choice Java_Web

Correct Answer
QUESTION DESCRIPTION

“request” is instance of which one of the following classes?


Score 1

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

Request

HttpRequest

HttpServletRequest

ServletRequest

No Comments

QUESTION 30 Java_Web_10 

Multiple Choice Java_Web

Wrong Answer
QUESTION DESCRIPTION

The doGet() method in the example extracts values of the parameter’s type and number by using
Score 0
__________

CANDIDATE ANSWER

Options: (Expected answer indicated with a tick)

request.getParameter()

request.setParameter()

response.getParameter()

response.getAttribute()

No Comments

PDF generated at: 12 Mar 2024 10:02:33 UTC

15/15

You might also like