Read and download the CBSE Class 12 Informatics Practices Java Gui Programming Worksheet in PDF format. We have provided exhaustive and printable Class 12 Informatics Practices worksheets for Java Gui Programming, designed by expert teachers. These resources align with the 2026-27 syllabus and examination patterns issued by NCERT, CBSE, and KVS, helping students master all important chapter topics.
Chapter-wise Worksheet for Class 12 Informatics Practices Java Gui Programming
Every student in Class 12 can use this Informatics Practices practice paper to review Java Gui Programming. Complete with important questions and solutions, regular self-testing will boost your confidence and improve your grades in school assessments and final tests.
Get Java Gui Programming Worksheet PDF for Class 12 Informatics Practices
CBSE Class 12 Informatics Practices Java GUI Programming. CBSE issues sample papers every year for students for class 12 board exams. Students should solve the CBSE issued sample papers to understand the pattern of the question paper which will come in class 12 board exams this year. The sample papers have been provided with marking scheme. It’s always recommended to practice as many CBSE sample papers as possible before the board examinations. Sample papers should be always practiced in examination condition at home or school and the student should show the answers to teachers for checking or compare with the answers provided. Students can download the sample papers in pdf format free and score better marks in examinations. Refer to other links too for latest sample papers.
UNIT-2
CHAPTER 3: JAVA GUI PROGRAMMING REVISION TOUR-I
Rapid Application Development: It describes a method of developing software through the use of pre-programmed tools or wizards. The pre-programmed tools or controls are simply dropped on a screen to visually design the interface of application. It enables program development in shorter time.
NetBeans Java IDE: It is a free, open-source, cross-platform IDE with built-in support for Java programming language. It has more advanced GUI building tools available in any open-source Java IDE.
Event: Occurrence of an activity.
Message: Information sent to the application or received from the application.
Types of Swing Components:
(a) Component: It is a self-contained graphic entity like JLabel, JTextField etc.
(b) Container: It can hold other components. It is of two types:
(i) Top Level Container: Can be displayed directly on a desktop. Every swing application must have at least one top level container, i.e. JApplet, JDialog, JFrame.
(ii) Non Top Level Container: Can be displayed within another top level container, i.e. JPanel, JScrollPane, JInternalFrame, JLayeredPane etc.
Page 1
Unit-2
Chapter 3: Java GUI Programming Revision Tour-I
Rapid Application Development (RAD): This refers to a software creation methodology that utilizes pre-made components or wizards. Developers can build interfaces visually by dragging and dropping these built-in controls directly onto a design screen. This approach significantly decreases the overall time required for application design.
NetBeans Java IDE: This is a cross-platform, free, and open-source Integrated Development Environment designed with built-in Java capabilities. It offers some of the most sophisticated graphical interface construction tools found among open-source Java environments.
Event: The trigger or happening of a specific action.
Message: Data or information directed to or received from a running program.
Types of Swing Components:
- Component: An independent graphical object, such as a
JLabelorJTextField. - Container: A component designed to house other sub-components. Containers are categorized into two primary categories:
- Top-Level Container: A window that can render directly on the user's desktop. Any Swing-based program requires a minimum of one top-level container, such as
JFrame,JDialog, orJApplet. - Non-Top-Level Container: A secondary container that must be embedded within another container to be shown, such as
JPanel,JScrollPane,JInternalFrame, orJLayeredPane.
- Top-Level Container: A window that can render directly on the user's desktop. Any Swing-based program requires a minimum of one top-level container, such as
Child Controls: These refer to individual control elements placed inside a parent container.
Java Character Set: This comprises the full list of valid symbols and letters that the Java compiler can detect. Java utilizes the Unicode standard for representing characters.
Data Types: These act as classification schemes to determine the nature of a data value and the permissible operations that can be executed on it.
Classification of Java Data Types:
- Reference Data Types:
- Classes
- Interfaces
- Arrays
- Primitive Data Types:
- Numeric:
- Integer:
byte,short,int,long - Floating Point:
float,double
- Integer:
- Character:
char - Non-Numeric:
- Boolean:
boolean
- Boolean:
- Numeric:
Page 2
Variables: A variable is an identified memory address designated to store a data value of a specific classification.
Variable Declaration and Initialization: When a variable is allocated memory and given an initial starting value, it is considered initialized. For example: int rollno = 1;
Text Interaction:
- getText() Method: Retrieves string input. Example:
String name = nametf.getText(); - setText() Method: Assigns or updates the displayed text in string-based GUI elements. Example:
ranktf.setText("1"); - Parse Methods: Converts text data into their numerical equivalents (e.g.,
Integer.parseInt()). - JOptionPane.showMessageDialog(): Renders a popup dialog or message window.
- System.out.print(): Sends output directly to the terminal console without appending a newline.
- System.out.println(): Writes output to the console window and automatically moves the cursor to the following line.
Variable Scope: This defines the specific section of a program where a variable remains visible and usable. A variable's accessibility is restricted to the block of curly braces {} in which it is defined.
Example of out-of-scope error:
if (condition) {
int x = 5;
// other code
}
System.out.println("The result is: " + x); // This line will trigger a compilation error because x is out of scope
Constant: A designated storage location in memory whose assigned value remains immutable throughout execution. Constants improve code readability, validation, and maintenance. Example: final int rateofinterest = 10;
Operator: A symbol that performs a specific calculation or task on entities called operands. Operators are classified based on the number of inputs they accept: Unary (processes a single operand, e.g., negative sign -), Binary (processes two operands, e.g., subtraction -), or Ternary (processes three operands, e.g., conditional operator ?:).
Type Conversion: The technique of translating a value from one native data type into another. This conversion happens in two ways:
- Implicit (Coercion): The compiler automatically promotes variables to the data type of the largest operand present in a multi-type equation.
- Explicit (Type Casting): Manually specified by the developer. Note that converting boolean values to other types is strictly prohibited. Syntax:
(type) expression. Example:(float) (x / 5 * y + 5)
Flow of Control Constructs:
- Sequential: Statements execute one after another in order.
- Selection: Conditional execution branches. Examples:
if,if...else,switch. - Looping (Iteration): Repeated execution of a block. Examples:
for,while,do...while. - Jump: Transferring execution control to other code parts. Examples:
break,continue,return.
Page 3
Selection Syntax Configurations:
| Basic Selection | Multi-way Selection |
|---|---|
If Statement:if (expression)If-Else Statement: if (expression)Nested If: if (expression) { | If-Else-If Ladder:if (expression)Dangling-Else Problem: if (expression)Indentation can misleadingly suggest the else aligns with the outer if, but it programmatically binds to the closest preceding unmatched if. |
The Switch Statement:
Syntax structure:
switch (expression) {
case constant_1:
statement_sequence_1;
break; // Note: The controlling expression must evaluate to byte, short, int, or char.
case constant_2:
statement_sequence_2;
break;
...
default:
statement_sequence_n; // Optional: The default branch can reside anywhere in the block.
}
Fall-Through: If a break statement is omitted in a switch construct, Java executes subsequent cases sequentially, ignoring matching conditions, until a break or the end of the block is reached.
Iteration (Looping) Statements:
Java supports three main types of loops: (i) for loop, (ii) while loop, and (iii) do-while loop.
Every loop consists of four key components: Initialization, Test Expression, Update Expression, and Loop Body.
For Loop Basic Example:
for (int i = 1; i <= 10; ++i) {
System.out.print(i + " ");
}
Factorial Computation Using a For Loop:
int fact = 1, a;
int num = Integer.parseInt(numtf.getText());
for (a = 1; a <= num; a++) {
fact = fact * a;
}
System.out.println("The factorial of " + num + " is " + fact);
Page 4
The While Loop: This is a top-tested, pre-tested, or entry-controlled looping construct.
Factorial Computation Using a While Loop:
int num = Integer.parseInt(numtf.getText());
long i = num, fact = 1;
while (num != 0) {
fact = fact * num;
--num;
}
System.out.println("The factorial of " + i + " is " + fact);
The Do-While Loop: This is an exit-controlled, post-tested, or bottom-tested loop. It guarantees that the loop body will execute a minimum of one time.
Syntax:
do {
statement;
} while (test_expression);
Example execution:
char ch = 'A';
do {
System.out.println(ch);
ch++;
} while (ch <= 'Z');
Jump Statements:
- Return: Exits from the current method or subroutine.
- Break: Immediately exits a
switch,for,while, ordo-whilestructure, shifting control to the line following the statement block. - Continue: Bypasses the remaining commands in the current iteration of a loop and triggers the evaluation of the next cycle.
Solved Questions:
Question 1. Write a java code to find out whether a year (4 digit number stored in a variable) is a leap year.
Answer:
You can implement the leap year check inside a button click event using nested conditions as follows:private void lybutActionPerformed(java.awt.event.ActionEvent evt) {
long yearValue = Long.parseLong(lytf.getText());
if (yearValue % 100 == 0) {
if (yearValue % 400 == 0) {
System.out.println(yearValue + " is a Leap Year");
} else {
System.out.println(yearValue + " is a Normal Century Year");
}
} else if (yearValue % 4 == 0) {
System.out.println(yearValue + " is a Leap Year");
} else {
System.out.println(yearValue + " is not a Leap Year");
}
}
In simple words: Get the year from the input field. If it is a century year, it must be divisible by 400 to be a leap year; otherwise, any year divisible by 4 is a leap year.
Exam Tip: Century years (like 1900 or 2000) have special rules for leap years, so ensure you handle both divisibility by 100 and 400 in your logic to score full marks.
Question 2. Write a java program to find the greatest out of three numbers.
Answer:
Below is the Java code block to read three integer inputs from text fields and determine the maximum value among them:int num1 = Integer.parseInt(tf1.getText());
int num2 = Integer.parseInt(tf2.getText());
int num3 = Integer.parseInt(tf3.getText());
if (num1 > num2 && num1 > num3) {
System.out.println(num1 + " is greater");
} else if (num2 > num3) {
System.out.println(num2 + " is greater");
} else {
System.out.println(num3 + " is greater");
}
In simple words: This code compares three input numbers using logical conditions to find which one is the largest.
Exam Tip: Remember to use the logical AND operator (&&) when combining multiple conditions in your conditional statements.
Page 5
Sample Questions
Question 1. What will be content of the jTextArea1 after executing the following code:
for (int i=2;i<=5;i++)
{ jTextArea1.setText(jTextArea1.getText()+" " + Integer.toString(i*i)); }
Answer:
Assuming that the text area initially contains no text, the final text inside jTextArea1 will be:4 9 16 25
Step-by-step Execution:
- i = 2: Appends " " + "4" to empty string. Text area displays:
4 - i = 3: Appends " " + "9" to previous content. Text area displays:
4 9 - i = 4: Appends " " + "16" to previous content. Text area displays:
4 9 16 - i = 5: Appends " " + "25" to previous content. Text area displays:
4 9 16 25
In simple words: The loop calculates the square of each number from 2 to 5 and appends them to the text area one after another separated by spaces.
Exam Tip: Pay close attention to whether the loop variable's limit uses < or <=, and check the initial content state of the text area when predicting output.
Question 2. Write java code that takes value for side of a square in jTextField1 and calculate area of it which is to be displayed in jTextField2.
Answer:
The following Java code retrieves the side length from the first text field, computes the area, and prints the result in the second text field:double side = Double.parseDouble(jTextField1.getText());
double area = side * side;
jTextField2.setText(Double.toString(area));
In simple words: Read the side value from the first box, multiply it by itself to find the area, and write that area value into the second box.
Exam Tip: Always parse inputs into floating-point numbers (like double or float) instead of integers when dealing with geometric dimensions, as side lengths can have decimals.
Question 3. Item code consisting of 5 digits is stored in a integer type variable intItemCode. Write the code for keeping this itemcode in a String type variable called strItemCode.
Answer:
You can convert the integer item code into a String format using any of the following standard approaches:
Method 1: Using Integer.toString()String strItemCode = Integer.toString(intItemCode);
Method 2: Using String.valueOf()String strItemCode = String.valueOf(intItemCode);
Method 3: Concatenation with an empty stringString strItemCode = "" + intItemCode;
In simple words: You can turn an integer variable into a text variable in Java easily by using Integer.toString().
Exam Tip: Using Integer.toString() or String.valueOf() is preferred over empty string concatenation as it is cleaner and visually self-documenting.
Question 4. What message will be displayed after the execution of the following code?
int age =64, relaxation = 4; modiage= age - relaxation;
if (modiage < 60) jOptionPane.showMessageDialog(null, "Not Eligible");
else jOptionPane.showMessageDialog(null, "Eligible");
Answer:
The popup window will display the message:Eligible
Explanation:
1. The value of modiage is computed as: \( 64 - 4 = 60 \).
2. The conditional expression modiage < 60 evaluates to 60 < 60, which is false.
3. Consequently, the program skips the if block and executes the else branch, displaying "Eligible".
In simple words: Subtracting 4 from 64 gives 60. Since 60 is not strictly less than 60, the program runs the else block and prints "Eligible".
Exam Tip: Be careful with strict relational operators like less-than (<). Since 60 is equal to 60 (not less than), the test fails, steering execution directly to the alternative else branch.
Question 5. Rewrite the following program code using if statement:
int c = jComboBox1.getSelectedIndex();
switch(c)
{ case 0 : amount = bill; break;
case 1 : amount = 0.9 * bill; break;
case 2 : amount = 0.8 * bill; break;
default : amount = bill;
}
Answer:
You can rewrite the switch code block using an if-else-if ladder as follows:int c = jComboBox1.getSelectedIndex();
if (c == 0) {
amount = bill;
} else if (c == 1) {
amount = 0.9 * bill;
} else if (c == 2) {
amount = 0.8 * bill;
} else {
amount = bill;
}
In simple words: This rewritten block checks each select index one by one using if statements and calculates the amount discount accordingly.
Exam Tip: Ensure that the final else branch contains the same logic as the original default clause of the switch statement to handle all other unhandled values correctly.
Free study material for Informatics Practices
Free CBSE Printable Worksheets: Class 12 Informatics Practices
Daily Practice Questions for Class 12 Informatics Practices
Enhance your test readiness by practicing the targeted questions provided for Java Gui Programming. Authored by experienced teachers in compliance with the recent 2026 CBSE guidelines for Class 12, these resources encourage active learning. We advise Class 12 students to complete these exercises regularly to reinforce core principles in Informatics Practices.
Verified Solutions & Answer Formats
Built using specifications from the active NCERT book for Class 12 Informatics Practices, these worksheets mirror authentic academic structures. Comparing your completed work with our expert-verified solutions ensures you learn standard formatting for CBSE exams. Supplement your study routine with the provided MCQ questions for Informatics Practices to touch upon every essential learning objective.
Boosting Grades with Free Informatics Practices Resources
Routine completion of these Class 12 Informatics Practices exercises ensures complete comfort with standard exam structures. Should any section of Java Gui Programming prove complex, our specialized NCERT solutions for Class 12 Informatics Practices provide straightforward explanations. Access our regularly updated collection of free printable assignments online to secure top grades in your evaluations.
FAQs
You can download the latest chapter-wise printable worksheets for Class 12 Informatics Practices Java Gui Programming for free from StudiesToday.com. These have been made as per the latest CBSE curriculum for this academic year.
Yes, Class 12 Informatics Practices worksheets for Java Gui Programming focus on activity-based learning and also competency-style questions. This helps students to apply theoretical knowledge to practical scenarios.
Yes, we have provided solved worksheets for Class 12 Informatics Practices Java Gui Programming to help students verify their answers instantly.
Yes, our Class 12 Informatics Practices test sheets are mobile-friendly PDFs and can be printed by teachers for classroom.
For Java Gui Programming, regular practice with our worksheets will improve question-handling speed and help students understand all technical terms and diagrams.