Java MP-1
Java MP-1
Certificate
Certificate
Certificate
Certificate
1 Introduction
2 Algorithm
3 Program Code
4 Outputs
5 Conclusion
INTRODUCTION
The Online Test App is a simple yet functional Java application designed to simulate a basic online
examination environment. Built using Java Swing, this desktop application provides an intuitive graphical
interface for users to navigate and answer a series of multiple-choice questions (MCQs). It demonstrates
core Java concepts and is specifically targeted toward beginners who want to understand how GUI-based
applications are developed in Java.
Project Objectives:
The primary objective of the project is to implement a multiple-choice test system that allows users to:
View questions and select answers from multiple choices.
Move between questions sequentially using the "Next" button.
Bookmark questions for later review using the "Bookmark" button.
Provide a clean, user-friendly interface for interacting with the test.
The simplicity of this project makes it a perfect tool for educational purposes or small-scale exams that do
not require extensive database support.
Key Features:
Multiple-choice questions: Each question offers four possible answers. The user can select only one
option, which is recorded for future review.
Bookmarking feature: The user has the option to bookmark questions. This feature helps in marking
uncertain questions and revisiting them before final submission.
Sequential navigation: Users can easily move from one question to the next using the “Next” button.
The system ensures that users cannot skip questions but allows them to return to bookmarked ones.
No Database Dependency: The project is designed to be lightweight and does not use any database
connectivity, making it ideal for demonstrating fundamental Java concepts without adding the
complexity of a backend system.
Java Concepts Explored:
Swing Framework: To create graphical user interfaces using components such as JFrame, JPanel,
JButton, JRadioButton, and JLabel.
Event Handling: The core of user interaction is built on event listeners. The app uses event handling
mechanisms to respond to button clicks and record the user's actions.
Flow Control: The app maintains control over navigation between questions using simple Java
constructs like loops, conditional statements (if-else), and array structures.
User Experience Design: While simple, the layout is designed to mimic real-world online test
interfaces, focusing on user ease and minimal learning curve.
ALGORITHM
1. Start.
2. Display a question with multiple choices.
3. User selects one option.
4. If the user clicks Next, validate the selected answer:
o If correct, store as correct.
o If incorrect, store as incorrect.
5. If the user clicks Bookmark, save the question for review later without validating the answer.
6. Repeat the above steps until the last question is answered or bookmarked.
7. Display the results (correct, incorrect, and bookmarked questions).
8. End.
FLOW CHART
PROGRAM CODE
package com.gainjava.knowledge;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JRadioButton;
JLabel label;
ButtonGroup bg;
OnlineTest(String s) {
super(s);
add(label);
bg = new ButtonGroup();
add(radioButton[i]);
bg.add(radioButton[i]);
btnNext.addActionListener(this);
btnBookmark.addActionListener(this);
add(btnNext);
add(btnBookmark);
set();
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
setLayout(null);
setLocation(250, 100);
setVisible(true);
setSize(600, 350);
if (e.getSource() == btnNext) {
if (check())
count = count + 1;
current++;
set();
if (current == 9) {
btnNext.setEnabled(false);
btnBookmark.setText("Result");
}
if (e.getActionCommand().equals("Bookmark")) {
add(bk);
bk.addActionListener(this);
m[x] = current;
x++;
current++;
set();
if (current == 9)
btnBookmark.setText("Result");
setVisible(false);
setVisible(true);
if (e.getActionCommand().equals("Bookmark" + y)) {
if (check())
count = count + 1;
now = current;
current = m[y];
set();
((JButton) e.getSource()).setEnabled(false);
current = now;
if (e.getActionCommand().equals("Result")) {
if (check())
count = count + 1;
current++;
System.exit(0);
radioButton[4].setSelected(true);
if (current == 0) {
if (current == 1) {
radioButton[0].setText("True");
radioButton[1].setText("False");
if (current == 2) {
label.setText("Que3: By Which Method You Can Set Or Change the Text in Label?");
radioButton[0].setText("setText()");
radioButton[1].setText("getText()");
if (current == 3) {
if (current == 4) {
radioButton[0].setText("MenuComponent");
radioButton[1].setText("MenuContainer");
radioButton[2].setText("ComponentMenu");
radioButton[3].setText("MenuBar");
if (current == 5) {
label.setText("Que6: What is The Default Layout for DialogBox?");
radioButton[0].setText("FlowLayout");
radioButton[1].setText("GridLayout");
radioButton[2].setText("CardLayout");
radioButton[3].setText("BorderLayout");
if (current == 6) {
radioButton[0].setText("Frame");
radioButton[1].setText("Applet");
radioButton[2].setText("Component");
radioButton[3].setText("Panel");
if (current == 7) {
radioButton[0].setText("setAlignment()");
radioButton[1].setText("getAlignment()");
radioButton[2].setText("getText()");
radioButton[3].setText("SetText()");
if (current == 8) {
label.setText("Que9: ");
radioButton[0].setText("true");
radioButton[1].setText("false");
radioButton[2].setText("don't know");
radioButton[3].setText("false");
if (current == 9) {
radioButton[0].setText("Attached()");
radioButton[1].setText("Detached()");
radioButton[2].setText("Persistent()");
radioButton[3].setText("Transient()");
boolean check() {
if (current == 0)
return (radioButton[1].isSelected());
if (current == 1)
return (radioButton[1].isSelected());
if (current == 2)
return (radioButton[0].isSelected());
if (current == 3)
return (radioButton[2].isSelected());
if (current == 4)
return (radioButton[0].isSelected());
if (current == 5)
return (radioButton[0].isSelected());
if (current == 6)
return (radioButton[1].isSelected());
if (current == 7)
return (radioButton[2].isSelected());
if (current == 8)
return (radioButton[0].isSelected());
if (current == 9)
return (radioButton[0].isSelected());
return false;
}
OUTPUTS
CONCLUSION
The "Online Test" application showcases the effective use of Advanced Java concepts to build interactive,
dynamic, and reliable systems. By leveraging technologies such as Servlets, JSP, JDBC, and session
management, this project demonstrates how Advanced Java can be used to create web-based solutions that
address real-world challenges.
This application streamlines the process of conducting assessments, providing features like secure user
authentication, randomization of questions, real-time test submission, and automated result calculation. The
use of a structured database enhances the application's efficiency and reliability, ensuring smooth data
management.
Through this project, we understand the significance of Advanced Java in creating enterprise-level web
applications. It emphasizes the role of Java in developing scalable, secure, and user-friendly platforms,
making it an essential skill set for modern software development. The Online Test project stands as a
testament to how Advanced Java can transform traditional processes into more accessible and automated
solutions.
• MARKS SECTION :
Prof.T.R.Kawade
Department of Computer Engineering
Dr.M.S Gosavi Polytechnic Nashik Road Nashik(1800) – 422101