0% found this document useful (0 votes)
3 views19 pages

Advanced Java-Question Bank

The document outlines a series of questions for a B.Tech Advanced Java course, covering topics such as Swing components, thread safety in collections, time complexity, and various Java collection classes and methods. It includes multiple-choice questions, theoretical questions, and programming tasks aimed at assessing students' understanding and application of Java concepts. The questions are categorized into modules and submodules, focusing on both theoretical knowledge and practical programming skills.

Uploaded by

Venkatesh Guthi
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)
3 views19 pages

Advanced Java-Question Bank

The document outlines a series of questions for a B.Tech Advanced Java course, covering topics such as Swing components, thread safety in collections, time complexity, and various Java collection classes and methods. It includes multiple-choice questions, theoretical questions, and programming tasks aimed at assessing students' understanding and application of Java concepts. The questions are categorized into modules and submodules, focusing on both theoretical knowledge and practical programming skills.

Uploaded by

Venkatesh Guthi
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/ 19

MVJ College of Engineering

DEPARTMENT OF
IVth Semester - B.Tech
Course : MVJ22IS42 - Advanced Java

QNo QUESTION CO MARK


Module 1
Submodule 1
Topic 1

1. Why are Swing components referred to as lightweight components? CO3 (2.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

2. What will happen if two threads access the same Hashtable simultaneously?

A. It will throw a Concurrent Modification Exception.

B. One thread will wait while the other completes its operation. CO1 (1.00)
C. Both threads will execute simultaneously without any issues.

D. It will lead to a data inconsistency.


( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

3. Which of the following legacy classes is synchronized in Java?

A. ArrayList

B. HashMap CO1 (1.00)


C. Vector

D. LinkedList
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

4. What is the time complexity of Collections.binarySearch() on a sorted list?

A. O(N)

B. O(N log N) CO1 (1.00)


C. O(log N)

D. O(1)
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

5. Which class provides a fail-safe iterator in Java?

A. HashSet

B. ConcurrentHashMap CO1 (1.00)


C. ArrayList

D. LinkedList
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

1 of 19
6. What is the expected output of the following program?

List<Integer> list = Arrays.asList(1, 2, 3, 4);

list.add(5);

System.out.println(list);

A. [1, 2, 3, 4, 5] CO1 (1.00)


B. [1, 2, 3, 4]

C. Compilation Error

D. UnsupportedOperationException
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

7. Which Java collection class provides constant-time performance for basic operations like add,

remove, and contains?

A. LinkedList
CO1 (1.00)
B. HashSet

C. TreeMap
D. PriorityQueue
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

8. Which collection class allows the retrieval of elements in FIFO (First In, First Out) order

in Java?
A. HashSet
CO1 (1.00)
B. LinkedHashMap
C. ArrayDeque

D. PriorityQueue
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

9. What is the time complexity of inserting an element into a TreeSet in Java?


A. O(1)

B. O(log n) CO1 (1.00)


C. O(n)

D. O(n log n)
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

2 of 19
10. Consider the following code snippet:

Map<String, Integer> map = new TreeMap<>();


map.put("Z", 10);

map.put("A", 20);
map.put("C", 15);

map.put("B", 25);
CO1 (1.00)
System.out.println(map);

What will be the output?


A. {Z=10, A=20, C=15, B=25}

B. {A=20, B=25, C=15, Z=10}


C. {A=20, C=15, B=25, Z=10}

D. {Z=10, C=15, B=25, A=20}


( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

11. Which of the following statements is true regarding the Java Collection Framework?
A. HashMap allows duplicate keys.

B. TreeSet maintains insertion order. CO1 (1.00)


C. LinkedHashMap maintains insertion order.

D. PriorityQueue allows null elements.


( MCQ ) ( Understanding(U) ) ( Easy ) (Ref : Unknown ) ( )

12. Differentiate between equals() and == with respect to string comparison


CO2 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

13. Differentiate between equals() and compareTo() with respect to string comparison
CO2 (2.00)

( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

14. Demonstrate a program to create a set of entries,display the elements and update it by adding an
balance to the following data
John Doe , 3433.34

Tom Smith, 123.22


Jane Baker, 1378.00
CO1 (10.00)
Tod Hall, 99.22
Ralph Smith, -19.08

Update John Doe account with 1000,Using TreeMap class.

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

15. Explain Vector class with an example using Enumeration interface to display the objects
CO1 (10.00)

( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

3 of 19
16. Demonstrate the legacy interfaces and classes used in Java Collections Framework with
CO1 (10.00)
appropriate example
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

17. Illustrate Array class and its methods used in Java Collections Framework with an example.
CO1 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

18. Illustrate the various Map classes used in Java Collections Framework with appropriate
example. CO1 (10.00)

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

19. Illustrate the various Map interfaces and its methods used in Java Collections Framework
CO1 (10.00)

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

20. Explain how collections can be accessed via an Iterator interface with an example
CO1 (10.00)

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

21. Summarize the comparator interface with example.


CO1 (10.00)

( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

22. Suggest a program for storing User-Defined classes in collections


CO1 (10.00)

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

23. Create a java program to create an ArrayList of objects of type string.Add any 5 strings,display

size & contents of list. Remove any 2 strings & display size and contents. CO1 (10.00)

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

24. Write an example for ArrayList class using Iterator, List Iterator, and for-each loop to display
CO1 (10.00)
elements.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

25. Illustrate the various collection interfaces and its methods used in Java Collections Framework
CO1 (10.00)

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

26. Illustrate the various collection classes used in Java Collections Framework with appropriate
CO1 (10.00)
example.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

27. Mention any four characteristics of Random interface


CO1 (2.00)
( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

28. Analyze the various changes that collection framework underwent recently CO1 (2.00)
( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

29. Write syntax and example for for-each loop CO1 (2.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

4 of 19
30. Differentiate between HashSet and TreeSet class CO1 (2.00)
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

31. What is Enumeration Interface and its methods CO1 (2.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

32. Sketch the hierarchy of Map interfaces. CO1 (2.00)


( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

33. Describe the purpose of Map.Entry interface with an example CO1 (2.00)
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

34. What is ArrayDeque class CO1 (2.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

35. Write stack class with an example CO1 (2.00)


( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )
Module 2
Submodule 1
Topic 1

36. Write a Java program that:

i)Converts a given string to uppercase.


ii)Removes any extra spaces at the beginning and end of the string. CO2 (10.00)
iii)Replaces all spaces within the string with underscores.
iv)Combines two given strings into one.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

37. Write a Java program to take a string input from the user and perform the following operations

using String Buffer:


i)Append a given string
CO2 (10.00)
ii)Insert a substring at a specific position
iii)Reverse the string

iv)Replace a part of the string


( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

38. Justify why StringBuffer is thread-safe compared to StringBuilder CO2 (2.00)


( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

39. Write a Java program that takes user input for different data types (integer, double, boolean) and
converts each to a string using String.valueOf(). The program should then concatenate all the CO2 (10.00)
converted strings and display the final result.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

40. What is String Buffer in Java? Write a Java program that demonstrates any four constructors of
CO2 (10.00)
String Buffer class.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

41. Develop a Java program that takes a user-input string, calculates its length using length(),

reverses it using reverse(), removes the first three characters using delete(), and deletes the last CO2 (10.00)

character using deleteCharAt().


( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

5 of 19
42.
Develop a Java program that takes a string input from the user, removes extra spaces, replaces all CO2 (10.00)
occurrences of 'a' with '@', extracts the first five characters, and appends _Processed.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

43.

Explain the following String methods with an example: CO2 (10.00)


i)contains() ii)contentEquals() iii)replaceFirst() iv)replaceAll() v)spilt() methods
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

44. Which method call is equivalent to String.valueOf(char[])?


A. String.copyOf(char[])
B. String.toString(char[]) CO2 (1.00)
C. new String(char[])
D. String.convert(char[])
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

45. What is the output of the following code?


int a = 25;
String s = String.valueOf(a);
System.out.println(s + 5);
CO2 (1.00)
A. 30

B. 255
C. 25 + 5
D. Compilation Error
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

46. Which of the following statements is true regarding valueOf()?


A. String.valueOf() returns a String object representation of the argument.

B. It throws a NullPointerException if the argument is null. CO2 (1.00)


C. String.valueOf() and toString() always behave the same way.
D. It can directly convert a char[] to a StringBuilder.
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

47. What will be the output of the following code?


StringBuffer sb = new StringBuffer("Java");

sb.insert(2, "Hello");
System.out.println(sb);
CO2 (1.00)
A. HelloJava
B. JaHellova
C. JavaHello
D. Compilation Error
( MCQ ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

6 of 19
48. What is the initial capacity of a StringBuffer object created using the default constructor?
A. 8
B. 16 CO1 (1.00)
C. 32
D. 64
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

49. What will be the output of the following code?


String s1 = new String("Hello");
String s2 = new String("Hello");

System.out.println(s1 == s2);
CO2 (1.00)
A. true
B. false
C. Compilation Error
D. Runtime Error
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

50. What will be the output of the following code?


char[] ch = {'J', 'A', 'V', 'A'};
String str = new String(ch, 1, 2);
System.out.println(str);
CO2 (1.00)
A. AV
B. JA
C. VA
D. Error
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

51. What is the correct way to create a String using a StringBuilder object?
A. String s = new String("StringBuilder");
B. String s = new String(new StringBuilder("Hello")); CO2 (1.00)
C. String s = StringBuilder.toString();
D. String s = new String(StringBuilder.toCharArray());
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

7 of 19
52. What will be the output of the following code?
byte[] arr = {65, 66, 67, 68};
String str = new String(arr);
System.out.println(str);
CO2 (1.00)
A. ABCD

B. 65 66 67 68
C. Error
D. NullPointerException
( MCQ ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

53. Which constructor is used to create a String using a subset of a character array?
A. String(char[] value, int offset, int count)

B. String(String str) CO2 (1.00)


C. String(char[] value)
D. String(byte[] bytes, String charset)
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

54. Write an example programs of searching strings using indexOf() and lastIndexOf( ) methods. CO2 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

55. Demostrate How to modify a string using replace() trim(), toLowerCase() toUpperCase()
methods with an example?
CO2 (10.00)

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

56. a. write a java program to demostrate the data conversion using valueOf() method
b. Develop a java code to compare whether the given two strings are equal or not using equals()
CO2 (10.00)
and compareTo()

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

57. a.Mention the methods of character extraction,charAt() getChars()getBytes()toCharArray() with


an examples.
b.Write an example program of startsWith() endsWith(), equals() Versus ==, CO2 (10.00)
compareTo(),compareToIgnoreCase() methods

( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

58. a. Illustrate any four-character extraction methods with examples.


b. Describe in details about string comparision, equals() equalsIgnoreCase(),regionMatches() CO2 (10.00)
with an example program.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

59. What is string in Java? Write a Java program that demonstrates any five constructors of String
CO2 (10.00)
class.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )
8 of 19
60. Differentiate between StringBuffer and String class
CO2 (2.00)
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

61. compare between StringBuffer and StringBuilder


CO2 (2.00)
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

62. Mention any two-character extraction methods of string class. CO2 (2.00)
( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

63. What is the output for the following program ?

class SubStringCons
{
public static void main(String args[])
{
byte ascii[] = {77, 86, 74, 67, 69};
CO2 (2.00)
String s1 = new String(ascii);
System.out.println(s1);
String s2 = new String(ascii, 3, 2);

System.out.println(s2);
}
}
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

64. What is the value of s for the following?


char chars[] = { 'm', 'v', 'j',’c’,’e’ };

String s = new String(chars);


CO2 (2.00)
System.out.println(s.length());

( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )


Module 3
Submodule 1
Topic 1

65. Which method is used for custom painting in Swing?

A) paintComponent(Graphics g)
B) repaint()
CO3 (1.00)
C) draw(Graphics g)
D) paint(Graphics g)
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

9 of 19
66. How do you create a group of mutually exclusive radio buttons in Swing?

A) By adding them to a JPanel

B) By using a ButtonGroup CO3 (1.00)


C) By implementing ActionListener for each button
D) By overriding the paint() method
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

67. What is the key difference between JButton and JToggleButton?

A) JButton can display images, but JToggleButton cannot


B) JButton remains pressed after being clicked, while JToggleButton does not CO3 (1.00)
C) JToggleButton acts like an on/off switch, while JButton does not
D) JButton requires an ActionListener, but JToggleButton does not
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

68. What is the purpose of JTextField in Swing?

A) To display images
B) To create a multi-line text area CO3 (1.00)
C) To allow users to enter a single line of text
D) To create a password field
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

69. How can you make a Swing button respond to user clicks?

A) By adding a KeyListener
B) By overriding the paint() method CO3 (1.00)
C) By adding an ActionListener

D) By implementing the Runnable interface


( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

70. What is the default layout manager for a JFrame's content pane?

A) FlowLayout
B) BorderLayout CO3 (1.00)
C) GridLayout

D) BoxLayout
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

71. Which of the following is used to display an image in Swing?

A) JLabel
B) JTextField CO3 (1.00)
C) JToggleButton
D) JDialog
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

10 of 19
72. Which package contains the core Swing classes?

A) java.swing
B) javax.swing CO3 (1.00)
C) java.awt.swing

D) swing.javax
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

73. In Swing, which of the following is NOT a top-level container?

A) JFrame
B) JDialog CO3 (1.00)
C) JPanel
D) JApplet
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

74. What design pattern does Swing use for separating UI components?

A) Singleton Pattern
B) Factory Pattern CO3 (1.00)
C) Model-View-Controller (MVC) Pattern

D) Observer Pattern
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

75. Which of the following is TRUE about Swing in Java?

A) Swing is built directly on top of the Java Virtual Machine (JVM)

B) Swing is a part of the java.awt package CO3 (1.00)


C) Swing is a lightweight component-based library
D) Swing components are always dependent on the native operating system
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

76. What is the primary reason for introducing Swing in Java?

A) To replace JavaScript

B) To provide a better alternative to AWT CO3 (1.00)


C) To enhance networking in Java
D) To develop mobile applications
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

77. Construct a Java program that implements Key Events, explaining how key presses trigger
CO3 (10.00)
different actions.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

78. Develop a Java program to handle Mouse Events, explain its working, and demonstrate how it
CO3 (10.00)
responds to different mouse actions.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

79. Design a Java GUI application using Swing that includes JLabel, JTextField, JButton, and event
CO3 (10.00)
handling. Explain the implementation.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )
11 of 19
80. Review the life cycle of an applet , explaining each stage with a real-time example and code. CO3 (10.00)
( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

81. Critique the Swing Hierarchy, discussing its advantages and limitations in Java GUI
CO3 (10.00)
development.
( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

82. Assess the Delegation Event Model in Java event handling and justify its usage in GUI
CO3 (10.00)
applications with an example.
( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

83. Investigate the difference between JRadioButton and JCheckBox with appropriate examples and
CO3 (10.00)
use cases.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

84. Examine the MVC architecture in Java GUI and explain its significance with a practical
CO3 (10.00)
example.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

85. Compare AWT and Swing in detail based on their architecture, event handling, and component
CO3 (10.00)
behavior.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

86. Analyze how Swing is built on AWT and differentiate its advantages over AWT with examples. CO3 (10.00)
( Theory ) ( Analyzing(A) ) ( Easy ) (Ref : Unknown ) ( )

87. Compare AWT (Abstract Window Toolkit) and Swing in Java. CO3 (2.00)
( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

88. Differentiate between a Window and a Frame in Java GUI programming. CO3 (2.00)
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

89. What is a container in a GUI? CO3 (2.00)


( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

90. Explain MVC (Model-View-Controller) in Java GUI applications.


CO3 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

91. How does a radio button in Java differ from a checkbox? CO3 (2.00)
( Theory ) ( Analyzing(A) ) ( Easy ) (Ref : Unknown ) ( )

92. List various Swing components available in Java. CO3 (2.00)


( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

93. Why does a Java applet not contain a main() method? CO3 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

94. Create a Java applet with dimensions 300 × 200 that displays "Hello" at the center. CO3 (2.00)
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

95. Explain in detail about methods of string length ,special string operations , string literals ,string
concatenation, string concatenation with other data types. CO2 (10.00)

( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )


Module 4
Submodule 1
Topic 1

12 of 19
96. Which of the following is used to store user-specific data in a JSP page across
multiple requests?

A) session
B) application CO4 (1.00)

C) page
D) request
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

97. Which JSP implicit object is used to get request data?

A) response
B) request CO4 (1.00)
C) session
D) application
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

98. What is the primary difference between JSP and Servlets?

A) JSP is used for logic, and Servlets are used for presentation
B) Servlets generate dynamic content, while JSP only displays static content CO4 (1.00)
C) JSP is mainly for the presentation layer, while Servlets handle business logic
D) There is no difference
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

99. Which JSP tag is used to include another file in a JSP page?

A) <jsp:import>
B) <jsp:include> CO4 (1.00)
C) <jsp:forward>
D) <jsp:load>
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

100. Which HTTP request method is used to send data in the request body?

A) GET
B) POST CO4 (1.00)
C) HEAD
D) DELETE
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

101. What is the correct method to read form data in a Servlet?

A) request.getParameter("name")

B) request.read("name") CO4 (1.00)


C) request.fetchParameter("name")
D) request.getValue("name")
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

13 of 19
102. Which package provides classes and interfaces for handling HTTP-specific functionality in
Servlets?
A) java.http
B) javax.servlet.http CO4 (1.00)
C) jakarta.servlet.http
D) org.apache.http

( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

103. Which web server is commonly used for developing and deploying Java Servlets?

A) Apache Tomcat
B) Nginx CO4 (1.00)
C) IIS
D) XAMPP
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

104. What are the stages in the life cycle of a Servlet?

A) Initialization, Compilation, Execution, Termination


B) Loading, Instantiation, Initialization, Service, Destruction CO4 (1.00)
C) Creation, Start, Run, Stop
D) Parsing, Executing, Stopping
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

105. What is the primary purpose of Servlets in Java?

A) To create desktop applications


B) To handle client requests and generate dynamic web content CO4 (1.00)
C) To manage databases directly
D) To replace HTML
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

106. Write a Servlet program to accept a user's name and age and display them on a web page. CO4 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

107. Develop a web application that handles both HTTP GET and POST requests using Servlets.
CO4 (10.00)
Provide the necessary code.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

108. Write a Servlet program to accept two parameters from a web page, and also write an HTML
CO4 (10.00)
script to create the input page for the Servlet program.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

109. Review the session management techniques in JSP and Servlets and recommend the best
CO4 (10.00)
approach for maintaining user data.
( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

14 of 19
110. Assess the importance of JSP over Servlets in web development and justify when to use each
CO4 (10.00)
technology.
( Theory ) ( Evaluate(E) ) ( Medium ) (Ref : Unknown ) ( )

111. Examine the key differences between GET and POST requests in Servlets and explain their
CO4 (10.00)
usage with code.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

112. Analyze how cookies and session tracking work in JSP and Servlets , explaining their differences
CO4 (10.00)
with examples.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

113. Develop a Servlet program that illustrates how to use cookies. CO4 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

114. Write a Servlet program to display "Welcome to MVJCE" on a web page. CO4 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

115. Write a Servlet program that demonstrates how to use session tracking with example CO4 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

116. Write a JSP program to create and read a cookie. Explain the process. CO4 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

117. Explain the difference between Servlets and CGI programs in terms of performance,
CO4 (10.00)
architecture, and execution.
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

118. Explain the life cycle of a Servlet with an example. CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

119. Explain how cookies are handled in JSP and Servlets, with an example. CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

120. List and explain the core classes of the javax.servlet package. CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

121. Describe the core interfaces provided in the javax.servlet.http package. CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

122. List and explain the various JSP tags with examples. CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

123. What is a session tracking Explain how to create a session using JSP. CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

124. Explain JSP scripting elements, tag and directive tags, with suitable examples. CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

125. Explain JSP and its advantages. Also, describe the life cycle of JSP with an example CO4 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

126. Analyze the difference between Cookies and HttpSession in Java web development. CO4 (2.00)
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

127. Write a JSP program to print the first 10 even and 10 odd numbers. CO4 (2.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

128. What is the difference between GenericServlet and HttpServlet? CO4 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

129. What is Session Tracking? Explain its significance in web applications. CO4 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

15 of 19
130. Define a Cookie and explain any two methods in the Cookie class CO4 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

131. What is the difference between the GET and POST methods in HTTP? CO4 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

132. Differentiate between Servlet and JSP. CO4 (2.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

133. List any four JSP implicit objects and explain their purpose. CO4 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

134. What is a servlet? Explain its role in Java-based web applications CO3 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

135. What is the HttpServlet class? Explain its purpose in Java web development. CO4 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )
Module 5
Submodule 1
Topic 1

136. What is the advantage of using a Connection Pool in JDBC?

A) Faster database connections


B) Reduced memory usage
CO5 (1.00)
C) Improved security
D) Increased query speed
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

137. What type of JDBC exception is thrown when a database access error occurs?

A) SQLException
B) DatabaseException CO5 (1.00)
C) IOException
D) QueryException
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

138. Which of the following JDBC interfaces provides information about the database,
such as table structure and supported SQL features?

A) DatabaseMetaData
B) ResultSetMetaData CO5 (1.00)

C) Connection
D) Statement
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

139. What happens if an SQL query inside a transaction fails in JDBC?

A) The transaction is automatically committed


B) The transaction is rolled back if rollback() is called CO5 (1.00)
C) The database connection is closed
D) The Java application crashes
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

16 of 19
140. How can you execute a parameterized SQL query in JDBC?

A) Using Statement
B) Using PreparedStatement CO5 (1.00)
C) Using CallableStatement
D) Using ResultSet
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

141. Which ResultSet method is used to move the cursor to the next row in the result set?

A) next()
B) moveNext() CO5 (1.00)
C) fetchNextRow()
D) advanceRow()
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

142. What is the primary purpose of a Statement object in JDBC?

A) To establish a connection to a database

B) To store SQL query results CO5 (1.00)


C) To execute SQL queries
D) To handle database metadata
( MCQ ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

143. Which method is used to establish a connection to a database in JDBC?

A) DriverManager.getConnection()
B) Connection.open() CO5 (1.00)
C) JDBC.connectDatabase()
D) Statement.createConnection()
( MCQ ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

144. What is the correct sequence of steps in a typical JDBC process?

A) Load Driver → Create Connection → Execute Query → Close Connection


B) Create Connection → Load Driver → Execute Query → Close Connection CO5 (1.00)
C) Load Driver → Execute Query → Create Connection → Close Connection
D) Execute Query → Load Driver → Create Connection → Close Connection
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

145. Which of the following JDBC driver types translates JDBC calls into ODBC calls?

A) Type 1
B) Type 2 CO5 (1.00)
C) Type 3

D) Type 4
( MCQ ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

17 of 19
146. Which package contains the core JDBC classes and interfaces?

A) java.sql
B) javax.jdbc CO5 (1.00)
C) java.jdbc
D) javax.sql
( MCQ ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

147. What is batch processing in JDBC? Explain its advantages and demonstrate how to use it with
CO5 (10.00)
an example.
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

148. Differentiate between Statement, PreparedStatement, and CallableStatement in JDBC with


CO5 (10.00)
examples.
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

149. Write a Java program to insert, update, delete, and retrieve records from a database using JDBC. CO5 (10.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

150. Compare connection pooling and normal database connections in terms of performance and
CO5 (10.00)
resource management.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

151. Examine the advantages and disadvantages of different JDBC drivers and explain which one is
CO5 (10.00)
best for web applications.
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

152. Develop a web-based employee management system using JSP, Servlets, and JDBC to perform
CO5 (10.00)
CRUD operations.
( Theory ) ( Create(C) ) ( Medium ) (Ref : Unknown ) ( )

153. Design an Employee Database System that stores employee details (empid, empname, empcity,
CO5 (10.00)
empsalary) and implement CRUD operations using JDBC
( Theory ) ( Analyzing(A) ) ( Medium ) (Ref : Unknown ) ( )

154. Write a Java program to create and retrieve a cookie with the cookie name “EMPID” and value
CO5 (10.00)
“AN2356”.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

155. Develop a Servlet program to accept a username from the client and display a greeting message:
“Hello UserName” CO5 (10.00)
“How Are You?”
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

156. Write a Java program to establish a database connection using a Type-4 JDBC driver and
CO5 (10.00)
retrieve data from a table.
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

157. Write a Java program to establish a connection between a Java application and a database using
CO5 (10.00)
the JDBC-ODBC Bridge .
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

158. What are Database Drivers? Discuss the different types of JDBC drivers with a neat diagram. CO5 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

18 of 19
159. Explain the different steps involved in JDBC connectivity with appropriate code snippets. CO5 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

160. Describe the following JDBC objects and their roles in database connectivity with example:
a) Database Connection
b) Statement Objects CO5 (10.00)

c) ResultSet
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

161. Explain any two key methods used in Transaction Processing with code snippets. CO5 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

162. Write a short note on Transaction Processing and explain its importance in database management
CO5 (10.00)
and with example
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

163. What is Metadata? Explain different types of Metadata with an example program. CO5 (10.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

164. Write any one syntax to establish a connection to a database using JDBC. CO5 (2.00)
( Theory ) ( Applying(P) ) ( Medium ) (Ref : Unknown ) ( )

165. Differentiate between Type-1 and Type-4 JDBC drivers . CO5 (2.00)
( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

166. Differentiate between Statement and PreparedStatement. CO5 (2.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

167. Differentiate between DatabaseMetaData and ResultSetMetaData. CO5 (2.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

168. Differentiate between SQLException and SQLWarning CO5 (2.00)


( Theory ) ( Understanding(U) ) ( Medium ) (Ref : Unknown ) ( )

169. Write a short note on Database Connection in JDBC. CO5 (2.00)


( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

170. Write a short note on Statement objects in JDBC CO5 (2.00)


( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

171. Write a short note on the ResultSet object in JDBC. CO5 (2.00)
( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

172. What is Transaction Processing? CO5 (2.00)


( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

173. List two key differences between DatabaseMetaData and ResultSetMetaData. CO5 (2.00)
( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

174. Define SQLException and SQLWarning CO5 (2.00)


( Theory ) ( Remembering(R) ) ( Medium ) (Ref : Unknown ) ( )

19 of 19

You might also like