Practical Examination for Full Stack
Java Programming (SE Sem-III)
Preamble: Examination Structure and Pedagogical
Rationale
Examination Overview
This practical examination is designed to comprehensively assess student competency in the
fundamental principles of Full Stack Java Programming, as outlined in the curriculum for the
third semester of the Software Engineering program. The examination is structured into five
distinct sections, each targeting a core area of the syllabus. The progression is logical,
beginning with foundational Java syntax, moving through the pillars of Object-Oriented
Programming (OOP), and concluding with an introduction to client-side web technologies. This
structure ensures that a student's understanding is evaluated from the ground up, testing both
discrete skills and the ability to integrate concepts.
Source Material Mapping and Assessment Objectives
All questions within this examination are derived directly from the concepts, theories, and code
examples presented in the official course lab manuals for Experiments 1 through 10. The
primary objective is to measure a student's ability to apply theoretical knowledge to practical
coding challenges. Key assessment objectives include:
● Syntactic Proficiency: The ability to write valid, error-free Java and JavaScript code.
● Algorithmic Problem-Solving: The capacity to design and implement solutions for
common programming tasks using appropriate control structures.
● Object-Oriented Design: The skill of modeling real-world problems using classes,
objects, inheritance, and interfaces.
● Code Robustness and Organization: The understanding of exception handling to create
resilient applications and the use of packages for code management.
● Web Fundamentals: The ability to structure web content with HTML and implement
client-side validation using JavaScript.
The following blueprint provides a transparent overview of the examination's structure, mapping
each section to its corresponding course material and indicating its relative importance.
Table 1: Examination Blueprint - Topic Distribution and Source
Mapping
Section Question Range Core Concepts Primary Source Approximate
Assessed Documents Weighting (%)
I 1-18 Looping 20%
Constructs (for,
while, do-while),
Section Question Range Core Concepts Primary Source Approximate
Assessed Documents Weighting (%)
Nested Loops,
Console Input
(BufferedReader)
II 19-42 Classes, Objects, 25%
Constructors,
Method &
Constructor
Overloading
III 43-57 Inheritance 20%
(Multi-level,
Hierarchical),
Interfaces,
Packages
IV 58-67 Exception 15%
Handling
(try-catch),
Custom
Exceptions
V 68-77 HTML (Structure, 20%
Forms, Tables),
JavaScript
(Validation,
Events, DOM)
Section I: Foundational Programming Constructs
(Questions 1-18)
This section assesses the student's grasp of fundamental Java control flow mechanisms and
console input/output operations. All questions requiring user input must be implemented using
the InputStreamReader and BufferedReader classes, as this approach introduces students to
stream-based I/O and the necessity of exception handling from the outset.
1. Write a Java program using a for loop to print all even numbers from 2 to 20.
2. Write a Java program using a while loop to calculate the sum of the first 15 positive
integers.
3. Write a Java program using a do-while loop to print the multiplication table of 7 up to 7
\times 10. The program must execute at least once, confirming the core feature of the
do-while loop.
4. Implement a Java program that calculates the factorial of a number (e.g., 5). Use a for
loop for the calculation.
5. Using a while loop, write a Java program to find the sum of all digits of a given number
(e.g., for 123, the sum is 6).
6. Write a Java program to print the following right-angled triangle pattern of asterisks using
nested for loops, similar to the "PyramidExample" :
*
* *
* * *
* * * *
* * * * *
7. Write a Java program to print the following inverted right-angled triangle pattern of
asterisks using nested for loops:
* * * * *
* * * *
* * *
* *
*
8. Write a Java program to print a pyramid of numbers as shown below for 5 rows:
1
2 2
3 3 3
4 4 4 4
5 5 5 5 5
9. Write a Java program to print the following number pattern:
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
10.Write a Java program to generate Floyd's Triangle for 4 rows:
1
2 3
4 5 6
7 8 9 10
11.Write a Java program to print a hollow square pattern of asterisks. For a size of 5, the
output should be:
* * * * *
* *
* *
* *
* * * * *
12.Write a Java program to print a full pyramid pattern of asterisks for 5 rows.
*
* *
* * *
* * * *
* * * * *
13.Write a Java program that prompts the user to enter their name using BufferedReader
and prints a welcome message, as demonstrated in the G5 class example.
14.Write a Java program that reads an integer from the user and prints whether the number
is prime or not. Use a loop for the primality test.
15.Implement the task mentioned in the lab manual: "WAP in java to reverse a three digit
number". The program must read the three-digit number from the user via the console.
16.Write a Java program that reads a string from the user and counts the number of vowels
(a, e, i, o, u) in it.
17.Write a Java program that reads integers from the user until they enter the number 0. The
program should then display the sum of all the positive numbers entered.
18.Using BufferedReader, read two integers from the user. Implement a program to find their
Greatest Common Divisor (GCD). In your source code, add a comment explaining why
the main method signature must include throws Exception when using [Link]()
without a try-catch block.
Section II: Principles of Object-Oriented Design
(Questions 19-42)
This section evaluates the student's ability to apply object-oriented principles by modeling
entities using classes, initializing them with constructors, and defining their behaviors with
methods, including the concept of overloading.
1. Create a Java class named Circle with an instance variable radius (of type double).
2. In the Circle class from the previous question, add a method calculateArea() that
computes and returns the area of the circle ($ \pi r^2 $).
3. Write a main method in a separate test class to create two Circle objects, set their radii,
and print their respective areas.
4. Define a class named Employee with instance variables for employeeId (int), name
(String), and monthlySalary (double).
5. In the Employee class, add a method calculateAnnualSalary() which returns the salary
multiplied by 12.
6. Add another method displayDetails() in the Employee class that prints all the employee's
information (ID, name, and monthly salary) to the console.
7. Create a class BankAccount with fields for accountNumber (String) and balance (double).
8. In the BankAccount class, implement a deposit(double amount) method that adds the
specified amount to the balance.
9. In the BankAccount class, implement a withdraw(double amount) method that subtracts
the amount from the balance, but only if sufficient funds are available.
10.Create a class Book with instance variables title (String) and author (String). Write a
default constructor that initializes these to "Unknown Title" and "Unknown Author".
11.Following the Student class example , add a parameterized constructor to the Book class
that accepts a title and an author as arguments to initialize the object.
12.Overload the constructor in the Book class. Create a third constructor that accepts only
the title, setting the author to "Anonymous".
13.Write a test class to create three Book objects, one using each of the three constructors,
and print their details.
14.Create a class Product with fields productId (int), name (String), and price (double).
15.Implement constructor overloading for the Product class:
○ A constructor that takes productId and name, setting the price to 0.0.
○ A constructor that takes all three attributes: productId, name, and price.
16.Create a Car class with fields make, model, and year. Provide a default constructor and a
parameterized constructor to initialize all fields.
17.In the Car class, add a method printCarInfo(). Create two Car objects in a main method,
one with the default constructor and one with the parameterized constructor, and call
printCarInfo() for both.
18.Create a utility class Calculator with a static method add(int a, int b) that returns their sum,
similar to the Adder class.
19.Overload the add method in the Calculator class to accept three integer arguments
add(int a, int b, int c) and return their sum.
20.Overload the add method again, this time by changing the data type. Create a version
add(double a, double b) that returns the sum of two doubles.
21.Create a class Geometry with an overloaded method calculateArea.
○ calculateArea(double side) for a square.
○ calculateArea(double length, double width) for a rectangle.
22.Create a class Printer with an overloaded method print.
○ print(String message)
○ print(int number)
○ print(double value) Each method should print the passed argument to the console
with a descriptive label (e.g., "String:...", "Integer:...").
23.Consider the following poorly designed class:
class MathOperations {
public int multiplyTwoIntegers(int a, int b) { return a * b; }
public double multiplyTwoDoubles(double a, double b) { return
a * b; }
public int multiplyThreeIntegers(int a, int b, int c) { return
a * b * c; }
}
Refactor this class to use a single, overloaded method named multiply. This demonstrates
how overloading improves program readability.
24.Write a main class to test your refactored MathOperations class. In a comment, briefly
explain how using a single method name (multiply) for related operations enhances code
maintainability for future developers working on the project.
Section III: Inheritance, Interfaces, and Packages
(Questions 43-57)
This section assesses understanding of class relationships, code reuse through inheritance,
contract implementation via interfaces, and code organization using packages.
1. Implement a single inheritance relationship. Create a Vehicle parent class with a speed
attribute and a displaySpeed() method. Create a Car child class that extends Vehicle and
adds a modelName attribute.
2. In a test class, create a Car object, set its speed and model name, and call the
displaySpeed() method inherited from Vehicle.
3. Implement the multi-level inheritance structure shown in the lab manual: Student -> Marks
-> Sports. Ensure that an object of the Sports class can access methods and fields from
both Marks and Student.
4. Write a main method to demonstrate the multi-level inheritance by creating a Sports
object and calling methods from all three levels of the hierarchy (getNo, getMarks,
getScore).
5. Implement the hierarchical inheritance structure from the lab manual: a single Student
superclass and three subclasses Science, Commerce, and Arts. The Student class
should have a method that is accessible by all subclasses.
6. Write a main method that creates one object for each of the three subclasses (Science,
Commerce, Arts) and demonstrates that each can call the shared method from the
Student parent class.
7. Fulfill the task from the lab manual: "Generate your own family tree using inheritance in
Java". Create a Grandfather class, a Father class that extends Grandfather, and a Son
class that extends Father. Each class should have a method that prints its role (e.g., "I am
the Grandfather.").
8. Define an interface named Drawable with a single abstract method void draw().
9. Create two classes, Circle and Rectangle, that both implement the Drawable interface.
Each class should provide its own implementation of the draw() method (e.g., print
"Drawing a Circle").
10.Implement a form of multiple inheritance using interfaces. Create an interface Engine with
methods start() and stop(). Create an interface MusicPlayer with methods playMusic() and
stopMusic(). Create a class SmartCar that extends Vehicle (from Q43) and implements
both Engine and MusicPlayer.
11.Fulfill the task from the lab manual: "Create a menu card of a cafe for billing using multiple
inheritance". Model this using an interface for billing (e.g., Billable with a calculateBill()
method) and a class for food items. Create a FinalOrder class that extends a
CustomerDetails class and implements the Billable interface.
12.Create a simple Java class SimpleCalculator inside a package named [Link]. The
class should have a public method to add two integers.
13.Create a Main class in a different package named [Link]. In this class, import the
SimpleCalculator class using the import [Link]; syntax and use it to add two
numbers.
14.Modify the Main class from the previous question to use the import package.*; syntax to
access the SimpleCalculator class. Provide the exact command-line instructions required
to compile and run this program, assuming the files are in their respective directory
structures (javac -d.... and java...).
15.You are designing a system to model animals. You have classes Bird and Fish. You need
to model the behavior of "flying" and "swimming". Which OOP mechanism is more
appropriate to model these behaviors: creating parent classes like FlyingAnimal and
SwimmingAnimal (inheritance), or creating interfaces like CanFly and CanSwim? Write a
short justification for your choice, explaining the difference between an "Is-A" relationship
and a "Can-Do" capability in this context.
Section IV: Robustness and Error Management
(Questions 58-67)
This section tests the ability to write robust Java applications by anticipating and handling
runtime errors using standard and custom exceptions.
1. Write a Java program that attempts to divide an integer by zero. Use a try-catch block to
catch the ArithmeticException and print a user-friendly error message, ensuring the
program does not crash and continues execution, as shown in the
JavaExceptionExample.
2. Write a program that declares an array of 5 integers. Use a try-catch block to handle an
ArrayIndexOutOfBoundsException that occurs when you try to access the element at
index 10.
3. Write a program that reads a string from the user and attempts to convert it to an integer
using [Link](). Wrap this logic in a try-catch block to handle the
NumberFormatException if the user enters a non-numeric string.
4. Write a program with a method that may throw multiple types of exceptions. Use a single
try block with multiple catch blocks to handle ArithmeticException and
ArrayIndexOutOfBoundsException separately, each with a specific error message.
5. Create a custom exception class named InvalidAgeException by extending the Exception
class, as demonstrated in the lab manual. It should have a constructor that accepts a
string message.
6. Write a validate(int age) method that throws your InvalidAgeException if the age is less
than 18. The method should otherwise print "Welcome to vote".
7. In a main method, call the validate method with an invalid age (e.g., 13) inside a try block
and catch the InvalidAgeException, printing the exception's message to the console.
8. Fulfill the task from the lab manual: "Create an exception for email id verification". Name it
InvalidEmailException. Write a method that throws this exception if a given email string
does not contain the "@" symbol.
9. Create a custom exception named InsufficientFundsException. In your BankAccount class
(from Section II), modify the withdraw method to throw this exception if the withdrawal
amount is greater than the current balance.
10.Consider a method boolean isPasswordValid(String password) that returns true if the
password length is greater than 8, and false otherwise. Refactor this method into void
validatePassword(String password) that throws a custom PasswordTooShortException if
the validation fails. In a comment, explain why the exception-based approach is more
flexible, as it separates the validation logic (the rule) from the handling logic (what to do
on failure), allowing it to be reused in different application contexts (e.g., console vs. web).
Section V: Web Content and Client-Side Logic
(Questions 68-77)
This final section assesses the ability to create structured web documents using HTML and
implement basic client-side interactivity and validation using JavaScript.
1. Create a static HTML page titled "My Bio". The page should include a main heading
(<h1>) with your name, a paragraph (<p>) describing your academic interests, and use at
least three different formatting tags such as <b>, <i>, and <mark>.
2. Design an HTML page that displays a simple weekly class schedule using an HTML
<table>. The table should have headers for "Time", "Monday", "Tuesday", etc. Populate at
least two rows with sample data.
3. Create an HTML page that contains two types of lists: an unordered list (<ul>) of your
favorite hobbies and an ordered list (<ol>) of the steps to log into your university's portal.
4. Design a complete HTML <form> for user registration. The form should include input
fields for:
○ First Name (<input type="text">)
○ Email Address (<input type="email">)
○ Password (<input type="password">)
○ Gender (using radio buttons <input type="radio">)
○ Country (using a dropdown <select> list with at least three options)
○ A submit button (<input type="submit">).
5. Create an HTML page with a button. Write a JavaScript function that displays an alert()
box with the message "Hello, World!" when the button is clicked. Use the onclick event
attribute.
6. Write an HTML page with a text input field and a button. Using JavaScript, write a function
that checks if the input field is empty when the button is clicked. If it is empty, display an
alert message "Username cannot be empty."
7. Create a simple HTML form with two password fields ("Password" and "Confirm
Password") and a submit button. Write a JavaScript function that is called on form
submission. The function should check if the values in the two password fields are
identical. If they are not, it should display an alert and prevent the form from submitting.
8. Implement the email validation program specified in the lab manual. Create an HTML
form with an email input field and a button. The associated JavaScript function must
check for the presence of both "@" and "." characters in the entered string. If either is
missing, an alert box should report the error.
9. Create an HTML page with a text area. Write a JavaScript function that dynamically
counts and displays the number of characters entered into the text area as the user types.
(Hint: Use the onkeyup event).
10.Create a user registration form with fields for "Username" and "Age". Write a single
JavaScript validation function that performs two checks:
○ The username must be at least 6 characters long.
○ The age entered must be a number greater than or equal to 18. If any validation
fails, display a specific alert message. This question synthesizes string
manipulation, numeric conversion, and conditional logic in JavaScript.
Appendix: Probabilistic Analysis of Final Examination
Questions (Q68-Q77)
This analysis determines the likelihood of each of the final 10 questions (Q68-Q77) being
selected for the last batch of students in a practical examination setting. The methodology
assigns a weighted score to each question based on factors that are critical in academic
assessment design.
Methodology
The probability score for each question is calculated as a weighted sum of four key factors. A
higher score indicates a higher likelihood of appearance.
1. Conceptual Complexity (40%): Measures the number of distinct concepts a question
integrates. A question combining HTML forms, JavaScript events, and multiple validation
rules is more complex and a better test of integrated skills than one testing a single HTML
tag.
2. Cumulative Knowledge / Thematic Synthesis (30%): Assesses the extent to which a
front-end question's logic mirrors a core concept taught in the Java portion of the course.
For instance, a JavaScript validation for age (>= 18) thematically synthesizes the
server-side custom exception logic for the same rule , making it an excellent "full-stack"
concept question.
3. Capstone Significance (20%): Evaluates how well a question serves as a final,
representative assessment of the client-side module. The email validation task is explicitly
presented as a standalone experiment , giving it high capstone significance.
4. Implementation Time (10%): A practical consideration. In a time-constrained exam,
questions that are concise yet conceptually rich are often preferred over those that require
extensive, repetitive coding.
Table 2: Probabilistic Likelihood Ranking for Final Question Set
(Q68-Q77)
Rank Q# Brief Complexit Synthesis Capstone Time Final Justificati
Descriptio y Score Score (of Score (of Score (of Weighted on
n (of 10) 10) 10) 10) Probabilit
y Score
(of 100)
1 75 Email 8 8 10 9 85 This
validation question
for "@" is the aim
and "." of an
entire
experime
nt. It has
high
complexit
y (form,
event, JS
string
methods),
high
thematic
synthesis
with
server-sid
e
validation
rules, and
is
explicitly a
capstone
task.
2 77 Validate 9 9 8 7 83 Excellent
username synthesis
length question.
Rank Q# Brief Complexit Synthesis Capstone Time Final Justificati
Descriptio y Score Score (of Score (of Score (of Weighted on
n (of 10) 10) 10) 10) Probabilit
y Score
(of 100)
and age The age
>= 18 validation
directly
mirrors
the Java
custom
exception
logic. It
combines
multiple
validation
types
(string
length,
numeric
compariso
n),
making it
highly
complex
and a
robust
test of
cumulativ
e
knowledg
e.
3 74 Confirm 7 6 7 8 68 A classic
password and
fields practical
match validation
task. It
tests
DOM
element
access,
compariso
n
operators,
and event
handling.
It has
Rank Q# Brief Complexit Synthesis Capstone Time Final Justificati
Descriptio y Score Score (of Score (of Score (of Weighted on
n (of 10) 10) 10) 10) Probabilit
y Score
(of 100)
moderate
complexit
y and is a
strong
represent
ative
problem
for form
validation.
4 73 Check if a 6 5 6 9 61 A
username fundamen
field is tal
empty validation
check. It
is less
complex
than other
validation
tasks but
serves as
a solid
test of
basic
DOM
manipulati
on,
conditiona
l logic,
and user
feedback
via alerts.
Its
simplicity
makes it
quick to
implement
.
5 71 Create a 7 2 5 6 50 This
complete question
HTML comprehe
registratio nsively
n form tests
Rank Q# Brief Complexit Synthesis Capstone Time Final Justificati
Descriptio y Score Score (of Score (of Score (of Weighted on
n (of 10) 10) 10) 10) Probabilit
y Score
(of 100)
knowledg
e of
various
HTML
form
elements.
While it
involves
no
JavaScrip
t and thus
has low
synthesis,
its
complexit
y in terms
of pure
HTML
structure
is high.
6 72 Simple 4 1 3 10 35 The most
"Hello, basic
World!" JavaScrip
alert on t event
button handling
click task. It
serves as
a good
entry-level
question
but lacks
the
complexit
y and
depth
expected
of a final
capstone
problem.
Its high
score on
implement
Rank Q# Brief Complexit Synthesis Capstone Time Final Justificati
Descriptio y Score Score (of Score (of Score (of Weighted on
n (of 10) 10) 10) 10) Probabilit
y Score
(of 100)
ation time
reflects its
simplicity.
7 76 Dynamic 6 2 4 5 39 This
character question
counter is
for a moderatel
textarea y
complex,
requiring
knowledg
e of a
different
event
(onkeyup)
.
However,
it lacks
the critical
validation
theme
present in
other
questions
and has
lower
capstone
significan
ce.
8 69 Create a 5 1 2 7 33 Tests a
class specific
schedule and
in an important
HTML HTML
table structure
(<table>).
It is a
purely
structural
task with
no
scripting
Rank Q# Brief Complexit Synthesis Capstone Time Final Justificati
Descriptio y Score Score (of Score (of Score (of Weighted on
n (of 10) 10) 10) 10) Probabilit
y Score
(of 100)
or
thematic
link to the
Java
portion,
making it
less likely
as a final,
integrated
question.
9 70 Create 3 1 2 9 27 This
ordered question
and tests
unordered fundamen
HTML tal HTML
lists list tags. It
is low in
complexit
y and has
minimal
capstone
value,
serving
better as
an
introducto
ry
exercise
rather
than a
final
assessme
nt.
10 68 Create a 2 1 1 10 21 The most
simple bio basic
page with question,
formatting testing
only
heading,
paragraph
, and
formatting
Rank Q# Brief Complexit Synthesis Capstone Time Final Justificati
Descriptio y Score Score (of Score (of Score (of Weighted on
n (of 10) 10) 10) 10) Probabilit
y Score
(of 100)
tags. It is
highly
unlikely to
be a final
question
for a
university-
level
exam due
to its very
low
conceptua
l
complexit
y.
Conclusion of Analysis
The analysis indicates that Question 75 (Email Validation) and Question 77 (Username and
Age Validation) are the most probable questions to appear for a final batch of students. Both
questions demand an integration of HTML and JavaScript skills, test critical validation logic,
and, most importantly, thematically connect to the server-side data integrity concepts taught in
the Java portion of the course. Their selection would reflect a deliberate pedagogical choice to
assess a student's holistic, or "full-stack," understanding of rule enforcement across different
layers of an application. Questions focusing on fundamental, static HTML (68, 69, 70) are least
likely, as they fail to assess the more advanced client-side scripting and validation skills that are
the capstone of this module.