This document describes an online test application project written in Java. It allows users to take a test consisting of 10 multiple choice questions. Users can navigate between questions using next and bookmark buttons. When finished, it displays the number of correct answers using a message box. The code sample shows how the questions, options, and navigation are implemented using classes like JFrame, JLabel, JRadioButton and event handlers.
2. :::ABSTRACT:::
This projectis based on the online test examination model,
such as RTO exam,Quize, Entrance Exam.In this there is an
series of question thatyou have to answer,on clicking the next
button will take you to the nextquestion.At last the resultwill be
displayedby clicking on the resultbutton, and the resultwill be
displayedby the message box.
3. :::CODE:::
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;
import javax.swing.*;
class OnlineTestextends JFrame implements ActionListener{
JLabellabel;
JRadioButtonradioButton[] = new JRadioButton[5];
JButton btnNext, btnBookmark,extra,bk[] = new JButton[9];
ButtonGroup bg;
int count = 0, current = 0, x = 1, y = 1, now =
0,z=0; int m[] = new int[10];
4. OnlineTest(String
s) { super(s);
label = new
JLabel(); add(label);
bg = new ButtonGroup();
for (int i = 0; i < 5; i++) {
radioButton[i] = new
JRadioButton();
add(radioButton[i]);
bg.add(radioButton[i]);
}
btnNext = new JButton("Next");
btnBookmark = new
JButton("Bookmark");extra =new
JButton();
extra.setBounds(500,40,100,20);
extra.setVisible(false);
add(extra);
btnNext.addActionListener(this);
btnBookmark.addActionListener(this);
add(btnNext);
add(btnBookmark);
set();
label.setBounds(30,40,450, 20);
6. }
if (e.getActionCommand().equals("Bookmark")){
bk[z] = new JButton("Bookmark" + x);
bk[z].setBounds(500,20 + 40 * x, 100,30);
extra.setText("jay");
//extra.setVisible(true);
//getContentPane().add(bk);
bk[z].addActionListener(this);
getContentPane().add(bk[z]);
z++;
m[x] =
current; x++;
current++;
set();
if (current == 9)
btnBookmark.setText("Result")
; repaint();
}
for (int i = 0, y = 1; i < x; i++, y++) {
if (e.getActionCommand().equals("Bookmark" +
y)) { if (check())
count = count + 1;
7. now =
current;
current =
m[y]; set();
((JButton)
e.getSource()).setEnabled(false);
current = now;
}
}
if
(e.getActionCommand().equals("R
esult")){ if (check())
count = count +
1;current++;
JOptionPane.showMessageDialog(this, "correct
answers= " + count);
System.exit(0);
}
}
void set() {
radioButton[4].setSelected(true)
; if (current == 0) {
label.setText("Que1:Where is Bose Institute ?");
radioButton[0].setText("gujrat");
radioButton[1].setText("Kolkata");
8. radioButton[2].setText("NewDelhi");
radioButton[3].setText("Dispur");
}
if (current == 1) {
label.setText("Que2:World Tourism Day is
celebrated
on-");
radioButton[0].setText(" September 27");
radioButton[1].setText("September 12");
radioButton[2].setText("September
25");
radioButton[3].setText("September
29t");
}
if (current == 2) {
label.setText("Que3:When is the International Yoga
Day
celebrated ?");
radioButton[0].setText("June 20");
radioButton[1].setText("June 21");
radioButton[2].setText(" April 22");
radioButton[3].setText("May 31");
}
if (current == 3) {
label.setText("Que4:'Line of Blood' is a book written
by
whom?");
radioButton[1].setText("BairajKhanna");
radioButton[0].setText("Ursula Vernon");
9. radioButton[2].setText("AmalEI-Mohtar");
radioButton[3].setText("DikshaBasu");
}
if (current == 4) {
label.setText("Que5: .........is the first woman to head
a
public sectorbank?");
radioButton[0].setText(" Usha
Ananthasubramanyan");
radioButton[1].setText("BairajKhanna");
radioButton[2].setText("Shikha Sharma");
radioButton[3].setText("Arundhati Bhattacharya");
}
if (current == 5) {
label.setText("Que6:Indian Army celebrated the
Poonch Link-up Day on which date?");
radioButton[0].setText("November21");
radioButton[1].setText("November25");
radioButton[2].setText("November24");
radioButton[3].setText("November 23");
}
if (current == 6) {
label.setText("Que7:The first Indian State to go
wholley
organic is -?");
radioButton[0].setText(" Sikkim");
radioButton[1].setText("Meghalaya");
10. radioButton[2].setText("Manipur");
radioButton[3].setText("Kerala");
}
if (current == 7) {
label.setText("Que8:What is the name of Indira
Gandhi's Samadhi?");
radioButton[0].setText("Shakti Sthal");
radioButton[1].setText(" Shanti Van");
radioButton[2].setText(" Shanti Sthal");
radioButton[3].setText(" Shanti Sthal");
}
if (current == 8) {
label.setText("Que9:Dallol GeothermalField belongs
to
which country?");
radioButton[0].setText("Ethiopia");
radioButton[1].setText(" Sudan");
radioButton[2].setText("Norway");
radioButton[3].setText("Russia");
}
if (current == 9) {
label.setText("Que10:In which state living root
bridges
are found?");
radioButton[0].setText("Meghalaya");
radioButton[1].setText("Assam");
15. Online Test App
Oue3: When is the International Yoga Day celebrated ?
June 20
June 21
≒ Apnl22
May 31
Next BooKnJark
O X
Online test App
Oue4: 'Line of Blood' is a book written by whom?
Ursula Vernon
. Bairaj Khanna
Annal E I-Mohtar
9 Diksha Bas u
Next Bookmark
O X
16. Online Test App
Oue5: .........is thefirst wom antohead a public sector bank?
'4? U sha A nanthasu bra manyan
f /J Bairaj K hanna
fiJ Shikha Sharma
f? Amndhati Bhattachary a
Next Bookmark
O X
Online Test App
Que6: Indian Army celebrated the Poonch Link-up Day on which date?
! November 21
'! November 25
November 24
NovemDera3
Ne*+ Bookmark
O X
17. : Online Test App
Oue8: Mat is thename ofIndira Gandhi's Samadhi?
q Shanti Sthal
Next Bookmark
Bookmark
Manipur
Oue7: The first Indian Statetogowholley organieis -?
OnlineTestApp
18. Result
Oue10: Inwhich statelivingroot bridges arefound?
Meghalay a
'≒ Assam
Manipur
Ddisha
BookmarkNect
Oue9: Dallol Geothermal Fieldbelongstowhichcountry?
Ethiopia
. Sudan
Russia
19. Oue10: In which state living root bridges are found?
Me ghalay d
Manipur
Odisha
Result
@UMANG TALPARA (BE/BTECH)
Mesh age
".. I .." correci answers - 2
OF