BCS613D AdvancedJava ImportantQ
BCS613D AdvancedJava ImportantQ
Badge guide:
Strategy: M1 is heavy on Collections API. Collection interface methods + ArrayList program + Legacy
classes = 30 marks combined. Both theory and programs asked.
Must Do Q1
ya ava
it J
What is a Collection Framework? Explain the methods defined by Collection / List
d
/ Navigable Set / Queue interfaces.
A ed
Cover: Collection Framework: unified architecture for storing/manipulating groups of objects.
i th anc
Interfaces: Collection (add,remove,contains,size,iterator), List (get,set,indexOf,subList), Set (no
duplicates), Queue (offer,poll,peek), Map. Hierarchy: Iterable→Collection→List/Set/Queue.
w v
Exam tip: Draw Collection hierarchy diagram. For each interface: list 4-5 key methods with
rn Ad
one-line description. = 10 marks.
e a D
Appeared: ALL 3 papers — exact same question every time
add(E e)
B C boolean Adds element to collection
import [Link].*;
public class ArrayListDemo {
public static void main(String[] args) {
ArrayList list = new ArrayList<>();
[Link]("Apple"); [Link]("Banana"); [Link]("Cherry");
[Link]("Date"); [Link]("Elderberry");
[Link]("Size: " + [Link]()); // 5
[Link]("Contents: " + list);
a ava
[Link]("Banana"); [Link]("Date");
it J
}
}
d
A ed
i th anc
Must Do Q3
w v
n Ad
Explain constructors of TreeSet class. Develop a Java program to create TreeSet
r
a D
collection and access it via an iterator. / Explain any four legacy classes of Java's
e
L 13
collection framework.
Cover: TreeSet: sorted set, no duplicates, NavigableSet. Constructors: TreeSet(),
S 6
TreeSet(Comparator), TreeSet(Collection), TreeSet(SortedSet). Legacy classes: Vector, Stack,
B C
Hashtable, Properties, Dictionary — pre-Java 2 classes.
Exam tip: TreeSet: write constructors + program with add/iterator/first/last. Legacy: table
with name/description/key method = 10 marks.
Appeared: ALL 3 papers
ya ava
dit J
A ed
i th anc
w v
rn Ad
e a D
L 13
S 6
B C
Must Do Q1
Illustrate StringBuffer methods: append(), insert(), reverse(), delete() with proper
examples. / Explain string modification methods of String class.
Cover: StringBuffer: mutable, thread-safe. append(str): adds at end. insert(offset,str): inserts at
position. reverse(): reverses string. delete(start,end): removes chars. replace(start,end,str): replaces
substring. deleteCharAt(index).
Exam tip: Write code snippet for each method showing before and after. = 10 marks.
Appeared: ALL 3 papers — StringBuffer methods appear every paper
a ava
[Link](" World"); // "Hello World"
[Link](5, ","); // "Hello, World"
[Link](); // "dlroW ,olleH" y
it J
[Link](); // back to "Hello, World"
d
A ed
[Link](5, 7); // "Hello World" (removes ", ")
i th anc
[Link](6, 11, "Java"); // "Hello Java"
[Link](0); // "ello Java"
w v
n Ad
[Link](sb); // Output: ello Java
r
a D
Must Do Q2 e
L 13
What is String in Java? Explain why string is immutable. Illustrate constructors of
6
String class with programs. / Compare equals() and == for string comparison.
S
B C
Cover: String immutable: stored in String pool, once created cannot change. Benefits: security,
thread-safety, caching, hashcode caching. Constructors: String(), String(String), String(char[]),
String(byte[]). equals(): compares content. ==: compares reference.
Exam tip: Immutability: 3 reasons + diagram of String pool. Constructors: 4 with code.
equals() vs ==: table + code example showing difference. = 10 marks.
Appeared: ALL 3 papers
equals() vs == Comparison
Constants, few
When to use Multi-thread string operations Single-thread string operations
modifications
Important Q4
dit J
A ed
Explain character extraction methods: charAt(), getChars(), toCharArray(). /
th anc
Explain indexOf() and lastIndexOf() methods.
i
w v
Cover: charAt(int index): returns char at given index. getChars(srcBegin,srcEnd,dst[],dstBegin):
rn Ad
copies chars to char array. toCharArray(): converts String to char[]. indexOf(str): first occurrence.
lastIndexOf(str): last occurrence.
e a D
Exam tip: Each method: syntax + 2-line description + one-line code example = 10 marks.
L 13
Appeared: ALL 3 papers — character methods always asked
Method
S 6Syntax Description Example Output
BC
charAt() char charAt(int index) Returns char at index "Hello".charAt(1) → 'e'
Strategy: M3: Swing features + programs = ALL papers. JFrame form program, event handling, radio
buttons, MVC pattern — all repeated. Programs are scoring — write complete working code.
Must Do Q1
Explain key features of Java Swing. Discuss the evolution of Java Swing. / What
is Java Swing? Explain its key features.
Cover: Swing features: (1)Platform independent (2)Lightweight components (3)MVC architecture
(4)Pluggable Look and Feel (5)Rich set of components (JButton,JLabel,JTextField etc) (6)Double
buffering (7)Event handling (8)Accessibility. Swing vs AWT: Swing=lightweight, AWT=heavyweight.
Exam tip: List 6-8 features as numbered points, 2 lines each. Add Swing vs AWT comparison
table. = 10 marks.
Appeared: ALL 3 papers
Must Do Q2
Develop a Java Swing application using JFrame that displays a simple form with
a ava
Name, Age fields, Submit button, and shows message dialog on click.
y
it J
Cover: JFrame: main window. JLabel: text label. JTextField: input field. JButton: clickable button.
d
A ed
ActionListener: handles button click. [Link](): shows popup.
Exam tip: Write complete program: import, class extends JFrame, constructor adds
i th anc
components, ActionListener shows dialog. = 10 marks.
w v
Appeared: Dec 2025 — program always asked
rn Ad
a D
JFrame Form Program — complete code
e
import [Link].*;
L 13
import [Link].*; import [Link].*;
S 6
public class SimpleForm extends JFrame implements ActionListener {
SimpleForm() {
B C
JLabel l1, l2; JTextField t1, t2; JButton btn;
a ava
ButtonGroup bg = new ButtonGroup();
[Link](this); y
[Link](r1); [Link](r2); [Link](r3); // only one selectable
it J
[Link](this);
[Link](this);
d
A ed
add(r1); add(r2); add(r3); add(label);
i th anc
w v
setLayout(new [Link]());
setVisible(true);
}
rn Ad
e a D
public void actionPerformed(ActionEvent e) {
L 13
[Link]("Selected: " + [Link]());
}
S 6
public static void main(String[] a) { new RadioDemo(); }
}
B C
Important Q4
Describe the MVC architecture in Java Swing. How is this design pattern
implemented in Swing applications?
Cover: MVC: Model (data/state), View (display/UI), Controller (handles input). In Swing:
JTextField=View, ActionListener=Controller, underlying data=Model. Example:
JTextfield(View)→ActionListener(Controller)→String data(Model).
Exam tip: Draw MVC diagram with arrows. Map Swing components to MVC roles. Code
example showing all three. = 10 marks.
Appeared: Dec 2025, June 2025 (2nd)
ya ava
dit J
A ed
i th anc
w v
rn Ad
e a D
L 13
S 6
B C
Strategy: M4: Servlet lifecycle appeared ALL 3 papers. JSP tags + servlet program = ALL papers. Cookie
handling + session tracking = important. Both theory and programs asked every time.
Must Do Q1
Explain the lifecycle of a Servlet with diagram. / Explain the lifecycle of a servlet
and how form data can be retrieved in Java Servlet.
Cover: Servlet lifecycle: (1)Loading & Instantiation (2)Initialization — init() (3)Request Handling —
service()→doGet()/doPost() (4)Destruction — destroy(). Form data:
[Link]("fieldname"). doGet() for GET, doPost() for POST.
Exam tip: Draw lifecycle diagram: load→init→service→destroy. For each phase: 2-line
description. Form data: code showing getParameter(). = 10 marks.
Appeared: ALL 3 papers
1. Loading [Link]()
ya ava
First request or startup JVM loads servlet class
4. Request
i th anc
service()→doGet/doPost Each request Handles client requests
Handling
w v
5. Destruction
r
destroy()
n Ad Server shutdown/reload Cleanup resources, save state
e a D
Must Do Q2
L 13
Develop a Java Servlet program to accept two parameters from webpage, find
S 6
sum and display result. Give necessary HTML script.
B C
Cover: Servlet extends HttpServlet. Override doPost(). Use [Link]() to get values.
Parse to int. Calculate sum. Use [Link]().println() to display result.
Exam tip: Write HTML form + Servlet class. Two files: [Link] + [Link]. = 10
marks.
Appeared: ALL 3 papers — servlet program with HTML always asked
<html><body>
<form action=SumServlet method=post>
Number 1: <input type=text name=n1>
Number 2: <input type=text name=n2>
<input type=submit value=Calculate Sum>
</form></body></html>
[Link]
Must Do Q3
Define JSP. Explain different JSP tags with suitable example programs. / Explain
types of JSP tags.
a ava
Cover: JSP tags: (1)Scriptlet <%...%> — Java code (2)Expression <%=...%> — output value
y
it J
(3)Declaration <%!...%> — declare variable/method (4)Directive <%@...%> — page settings
d
(5)Comment <%--...--%> — JSP comment (6)Action tags , .
A ed
Exam tip: Each tag: syntax + one-line description + 2-line code example. = 10 marks.
Appeared: ALL 3 papers
i th anc
Tag Type Syntax
w v Purpose Example
Expression
e a D
<%= expression %> Output value directly <%= new [Link]() %>
Declaration
L 13
<%! declaration %> Declare variable/method <%! int count=0; %>
Directive
S 6
<%@ directive %> Page-level settings <%@ page language="java" %>
Comment
B C
<%-- comment --%>
JSP comment (not in
output)
<%-- This is hidden --%>
Must Do Q4
What is a Cookie? List methods defined by Cookie class. Develop a Java program
to add a cookie. / Explain session tracking with examples.
Cover: Cookie: small text file stored on client browser. Cookie class methods: getName(),
getValue(), setMaxAge(), getMaxAge(), setPath(), getDomain(). Session tracking: Cookies, URL
rewriting, Hidden fields, HttpSession. HttpSession: setAttribute(), getAttribute(), invalidate().
Exam tip: Cookie methods: table. Cookie program: addCookie() + getCookies(). Session:
HttpSession code example. = 10 marks.
Appeared: ALL 3 papers — cookies/session always in M4
Strategy: M5: JDBC steps + JDBC drivers = ALL papers. Statement types (Callable, Prepared) = ALL
papers. Database programs (connect, insert, display records) = ALL papers. Very predictable module.
Must Do Q1
Explain the four types of JDBC drivers. / Elaborate on concepts of JDBC and
discuss types of JDBC drivers.
Cover: JDBC drivers: Type 1 (JDBC-ODBC Bridge): uses ODBC driver, slow, deprecated. Type 2
(Native-API): uses DB vendor's native library. Type 3 (Network Protocol): middleware server
converts JDBC calls. Type 4 (Thin/Pure Java): directly communicates with DB, fastest, most
common (MySQL Connector/J).
Exam tip: Draw diagram showing 4 types with Java→Driver→Database path. Table:
type/name/pros/cons. = 10 marks.
Appeared: ALL 3 papers
y
Easy setup / Slow, deprecated
Type 2 Native-API
dit J
Uses DB-specific native libraries Fast / Platform dependent
w v
Must Do Q2
rn Ad
e a D
Construct a code snippet describing various steps involved in JDBC process. /
Explain steps in JDBC process to connect to a database.
L 13
Cover: JDBC steps: (1)Load driver: [Link]() (2)Get connection:
S 6
[Link](url,user,pwd) (3)Create statement: [Link]() (4)Execute
query: [Link](sql) (5)Process ResultSet: [Link](), [Link]() (6)Close: [Link](),
BC
[Link](), [Link]().
Exam tip: Write 6 steps as numbered list + code for each step. = 10 marks.
Appeared: ALL 3 papers
ya ava
Must Do Q3
dit J
A ed
What is Statement object in JDBC? Explain Callable Statement and Prepared
Statement objects.
i th anc
Cover: Statement: executes simple SQL. PreparedStatement: precompiled SQL with parameters
w v
(faster, prevents SQL injection). CallableStatement: calls stored procedures. PreparedStatement:
n Ad
[Link]('INSERT INTO ? VALUES (?,?)'), setInt(1,val), execute().
r
marks. e a D
Exam tip: 3 statement types: definition + when to use + code snippet. Comparison table. = 10
L 13
Appeared: ALL 3 papers
Statement Type
S 6
When to use Key Methods Example
Statement B C
Simple, one-time SQL execute(), executeQuery(), [Link]("SELECT *
queries executeUpdate() FROM t")
cs=[Link]("{call
CallableStatement Execute stored procedures setInt(), registerOutParameter()
proc(?,?)}")
Must Do Q4
Develop a Java program to connect to database, insert a student record and
display confirmation. / Develop program to retrieve and display all records from
employees table using ResultSet.
Cover: Connect with [Link](). For insert: PreparedStatement with
setString/setInt, executeUpdate(). For select: Statement, executeQuery(), while([Link]()) iterate.
ResultSet metadata: getColumnCount(), getColumnName().
Exam tip: Two programs: Insert program (7 lines) + Select/display program (10 lines). = 10
marks.
Appeared: ALL 3 papers — database program always asked
// INSERT program
Connection con = [Link](url, user, pass);
PreparedStatement ps = [Link](
"INSERT INTO students(id, name) VALUES(?, ?)");
[Link](1, 101); [Link](2, "Aditya");
int rows = [Link]();
[Link](rows + " record inserted successfully!");
// DISPLAY ALL RECORDS program
Statement stmt = [Link]();
ResultSet rs = [Link]("SELECT * FROM students");
while([Link]()) {
[Link]([Link]("id") + " " + [Link]("name"));
}
Important Q5
Explain database metadata and ResultSet metadata. / Compare Statement and
ResultSet objects in JDBC.
a ava
Cover: DatabaseMetaData: info about database (getDatabaseProductName, getDriverVersion,
y
getTables). ResultSetMetaData: info about result columns (getColumnCount(), getColumnName(i),
it J
getColumnType(i)). Useful for dynamic column display.
d
A ed
Exam tip: DatabaseMetaData: 4 methods with description. ResultSetMetaData: loop through
columns using getColumnCount(). = 10 marks.
i th anc
Appeared: ALL 3 papers — metadata always asked
w v
rn Ad
TOP 15 MUST PREPARE QUESTIONS — All from 3 PYQs: M1: Collection Framework methods +
e a D
interfaces diagram — ALL papers M1: ArrayList program (add/remove/display) — ALL papers M1:
L 13
TreeSet with iterator OR Legacy classes table — ALL papers M2: StringBuffer methods
6
(append/insert/reverse/delete) with code — ALL papers M2: String vs StringBuffer vs StringBuilder
S
B C
table — ALL papers M2: equals() vs == comparison with code — ALL papers M3: JFrame form program
(Name+Age+Submit+dialog) — ALL papers M3: Event handling mechanism + Radio button program —
ALL papers M3: Swing features/key features list — ALL papers M4: Servlet lifecycle diagram + 5
phases — ALL papers M4: Servlet program with HTML form (sum/login) — ALL papers M4: JSP tags
table (6 types with syntax) — ALL papers M5: JDBC 4 driver types table — ALL papers M5: JDBC 6
steps with complete code — ALL papers M5: PreparedStatement vs Statement + DB program — ALL
papers