Unit 2 • 25 Marks / 45 Periods Ch 4 (11M) + Ch 5 (10M) + Ch 6 (4M) Bureau Textbook pp. 107–210

Unit 2: Introduction to Programming (Java, NetBeans IDE & Swing)

Covers Chapters 4, 5 & 6 (PDF pp. 107–210): RAD & NetBeans Workspace, Java Swing GUI Controls & Events, Java Tokens/Data Types/Operators/Control Flow, and Coding/Error/GUI Development Guidelines. Includes complete solved textbook programs & output traces.

Official Weightage 25 / 70 Marks (35.7%)
Teaching Periods 45 Periods (20+15+10)
GUI Framework NetBeans & Java Swing
PDF Pages pp. 107 – 210
Unit 2 Visual Mindmap

Unit 2 Mindmap: Java IDE, Swing GUI, Fundamentals & Guidelines (25 Marks)

Interactive breakdown of Chapters 4, 5 & 6 for both Theory (25M) and Practical (30M).

Unit 2: Introduction to Programming — Chapter Mindmap
Unit 2: Introduction to Programming (25 Marks • 45 Periods)
Ch 4 Programming using IDE (11M) + Ch 5 Fundamentals (10M) + Ch 6 Guidelines (4M)
  • History: 1991 Green Project (Oak) → Java (1995, James Gosling); WORA (Bytecode on JVM)
  • JDK Tools: javac, java, javadoc, jar, appletviewer, jdb
  • RAD = ICU: Iterative development, Construction of prototypes, CASE tools
  • NetBeans IDE: Palette, Inspector (component tree!), Design/Source, Properties, Guarded Blocks, Shift+F6
  • AWT vs Swing: Heavyweight OS peers vs Lightweight JComponent + Pluggable Look & Feel (PLAF)
  • Events: Event Object + Event Source + Event Listener (actionPerformed)
  • Core Widgets: JFrame, JPanel, JLabel, JTextField, JTextArea, JButton, JCheckBox, JRadioButton (ButtonGroup)
  • Selection/Dialogs: JComboBox, JList, JPasswordField (getPassword()), JOptionPane (-1/0/1/2)
  • Basics: 16-bit Unicode, 50 Keywords, Identifiers, Escape sequences (\n,\t)
  • 8 Primitives: byte(1), short(2), int(4), long(8), float(4), double(8), char(2), boolean(reserves 8-bit/uses 1-bit)
  • Reference Types: Classes (String), Arrays, Interfaces, enum
  • Parsing & Ops: Integer.parseInt, Double.parseDouble; ++ pre/post, ?:, &&/||
  • Selection: if, if-else, ladder else if, switch(int/char) + break fall-through
  • Loops: Entry-controlled for & while (0+ runs) vs Exit-controlled do-while (at least 1 run)
  • Jumps: break (exits loop/switch) vs continue (skips to next iteration)
  • Modularity: Top-Down vs Bottom-Up design; 11 Good Coding Guidelines
  • 3 Error Types: Compile-Time (Syntax & Semantic), Run-Time (Exception), Logical (wrong formula)
  • Debugging: Locate → Isolate root cause → Correct & Re-test
  • 6 GUI Stages: Analysis → Design → Coding → Testing & Debugging → Documentation → Delivery/Maintenance
  • Verification vs Validation: "Building the system right" vs "Building the right system"
  • Tests: White-box (code paths), Black-box (I/O specs), Unit testing
Chapter 4 • Official Bureau Syllabus

Programming Using IDE (Java, NetBeans RAD & Swing Components)

11 Marks 20 Periods PDF pp. 107–150
Highest-Weight Chapter in the Entire Book (11 Marks / 20 Periods): Questions test NetBeans window names, JFrame vs JDialog, JCheckBox vs JRadioButton, JList vs JComboBox, JPasswordField.getPassword(), and writing short GUI event snippets!

4.1 Java WORA, JDK Tools, RAD & NetBeans IDE Workspace

Java Compilation Pipeline (WORA) and NetBeans IDE Windows Diagram Top flow shows Source.java compiled by javac into platform-independent Bytecode .class interpreted by JVM on Windows, Linux, or macOS. Bottom shows NetBeans RAD workspace components. 1. Java Compilation & WORA Execution Pipeline (Ch 4) Source Code MyApp.java javac Compiler Syntax/Semantic Check Bytecode MyApp.class (Portable) JVM (java Interpreter) Runs on Windows / Linux / macOS 2. NetBeans RAD Workspace & JDK Tools (PDF pp. 108–118) Projects / Inspector • Projects & Files tree • Inspector shows visual & non-visual Swing tree GUI Design / Source Editor • Drag-and-drop Swing form canvas • Guarded Blocks (grey read-only init) • Run active file shortcut: Shift + F6 Palette & Properties • Palette: Swing controls • Properties: text, font, model, buttonGroup RAD = I C U I: Iterative dev C: Construction U: Use of CASE tools
Figure 2.1: Java Compilation (WORA) Pipeline & NetBeans IDE Workspace (Ch 4, pp. 107–118).
JDK Core Tools (PDF p. 108)
  • javac: Java Compiler (.java → .class bytecode).
  • java: Java Application Launcher / JVM Interpreter.
  • javadoc: Generates HTML API docs from /** ... */ comments.
  • jar: Packages classes/resources into compressed .jar archive.
  • appletviewer / jdb: Runs Java applets / Java debugger.
AWT vs Swing & Event Model
  • AWT (java.awt): Heavyweight components tied to OS native peers; looks differ across OSes.
  • Swing (javax.swing): Lightweight (written 100% in Java), supports PLAF (Pluggable Look and Feel), prefix J (e.g., JButton).
  • Event Handling (Delegation Model): Event (ActionEvent/click) → Event Source (JButton) → Event Listener (ActionListener running actionPerformed(evt)).
Java Swing Class and Container Hierarchy Hierarchy rooted at java.lang.Object to java.awt.Component, splitting into Container, Window (JFrame, JDialog), and javax.swing.JComponent (JLabel, JTextField, JButton, JCheckBox, JRadioButton, JComboBox, JList, JPanel, JOptionPane). Component → Container Top-Level Window Containers JFrame Main desktop window Title bar, min/max/X defaultCloseOperation JDialog Secondary popup Modal / Non-Modal Depends on parent javax.swing.JComponent (Lightweight Components) Text & Buttons JLabel • JButton JTextField • JTextArea JPasswordField (getPassword() → char[]) Selection Controls JCheckBox (multi) JRadioButton (+ Group) JComboBox (drop+edit) JList (scroll list) Containers & Popups JPanel (sub-container) JScrollPane JOptionPane (-1, 0 Yes, 1 No, 2 Cancel)
Figure 2.2: Java Swing Top-Level Containers & JComponent Widget Family (Ch 4, pp. 119–146).

4.2 Complete Swing Controls, Properties & Methods Reference (pp. 122–146)

Swing Control Purpose / Behavior Key Properties & Common Java Methods
JLabelDisplays non-editable read-only text or icon.text, font, foreground, background, enabled, toolTipText; getText(), setText(str), setEnabled(), setToolTipText()
JTextFieldSingle-line editable text box (read-only if editable=false).text, editable, font, foreground, background, enabled, toolTipText; getText(), setText(str), setEditable(bool), setEnabled(), setToolTipText()
JTextAreaMulti-line text box inside a JScrollPane.rows, columns, lineWrap, editable; append(str), getText(), setText(str)
JButtonTriggers an action on click via ActionListener.text, label, font, foreground, background, enabled, mnemonic; getText(), setText(str), doClick(), setEnabled(bool)
JCheckBoxSquare toggle allowing multiple independent selections.selected, text, label, font, foreground, buttonGroup; isSelected(), setSelected(bool), getText(), setText()
JRadioButtonRound option button inside a ButtonGroup for mutually exclusive choice.buttonGroup, selected, text, label, font, background, foreground, enabled; isSelected(), setSelected(bool), getText(), setText()
ButtonGroupNon-visual container ensuring only 1 radio button in group is selected.Visible in NetBeans Inspector window; add(), getSelection(), clearSelection()
JComboBoxDrop-down list + optional editable text field (saves form space).model, editable, enabled, background, buttonGroup; getSelectedItem(), getSelectedIndex(), setModel(), addItem()
JListScrollable vertical list supporting Single or Multiple interval selection.model, selectedIndex, selectedItem, selectionMode, font, enabled; getSelectedValue(), getSelectedIndex(), getSelectedValuesList()
JPasswordFieldMasks keystrokes using echoChar (default */bullet).echoChar, editable, font; getPassword() returns char[] (new String(pf.getPassword()))
JOptionPane / DefaultTableModelModal dialogs (Message/Input/Confirm/Option) & JTable data model.showMessageDialog(), showInputDialog(), showConfirmDialog() returns -1 (Closed), 0 (Yes/OK), 1 (No), 2 (Cancel); DefaultTableModel.addRow()
Step-by-Step NetBeans GUI Form Building Guide (Exam & Practical):
  1. Click File → New Project → Java → Java Application → Finish.
  2. Right-click package → New → JFrame Form → switch between Design and Source tabs.
  3. Drag JLabel, JTextField, JRadioButton / ButtonGroup, and JButton from Palette onto the Design canvas.
  4. Right-click each widget → Change Variable Name (e.g., txtUnits, btnCalc) and configure text/font in Properties.
  5. Double-click the button (or right-click → Events → Action → actionPerformed) to write Java code inside the editable body below Guarded Blocks.
  6. Press Shift + F6 to compile and run the form immediately.
CHSE Syllabus Unit Reference: Chapter 4: Programming using IDE (pp. 107–150)
Aligned with Odisha State Bureau Higher Secondary (+2) IT Part - I syllabus (Reference pp. 107+). All topic summaries, diagrams, and solved exercises are included directly on this page.
Chapter 5 • Official Bureau Syllabus

Programming Fundamentals (Data Types, Operators, Parsing, Decisions & Loops)

10 Marks 15 Periods PDF pp. 151–196

5.1 Character Set, 50 Keywords, Primitive vs Reference Types & Parsing

  • Character Set & Tokens: Java uses 16-bit Unicode. 50 Reserved Keywords (lowercase, e.g., class, public, boolean, switch, const, goto) cannot be used as identifiers. Identifiers start with a letter, _, or $ (never a digit).
  • Escape Sequences: \n (Newline), \t (Tab), \b (Backspace), \" (Double quote), \' (Single quote), \\ (Backslash).
Java 8 Primitive Data Types, Reference Types, and String Parsing Methods Breakdown of 8 Java primitive types with exact byte sizes vs Reference types (String, Array, Class, Interface, enum) and String-to-number conversion methods. 8 Primitive Data Types in Java (Store Values Directly) Integer Types (Signed) • byte (1B: -128..127) | short (2B) • int (4B, default) | long (8B, L suffix) Default int value = 0 Floating-Point Types • float (4B, 6–7 dec digits, f suffix) • double (8B, 15 dec digits, default) Default double value = 0.0d Character & Boolean • char: 2 Bytes (16-bit Unicode '\u0000') • boolean: Reserves 8-bit, uses 1-bit (Textbook Ch 5 MCQ rule!) Non-Primitive / Reference • Classes (String!), Arrays, Interfaces • Textbook lists enum here too Store heap address; default = null Swing Input → Number Parsing jTextField1.getText() returns String! Integer.parseInt(s) String → int (for arithmetic) Double.parseDouble(s) String → double (decimal) String.valueOf(x) / "" + x Number → String for setText()
Figure 2.3: Java Primitive & Reference Types + Wrapper Class Parsing for Swing GUI Apps.

5.2 Java Operators & Precedence Exam Rules

  • Prefix vs Postfix (++a vs a++): Prefix changes value first then uses it; Postfix uses existing value in expression then increments/decrements.
  • Integer Division Trap: 7 / 2 == 3 (both int), whereas 7.0 / 2 == 3.5 (widened to double). Modulo % keeps dividend sign (7 % 2 == 1).
  • Ternary Operator: max = (a > b) ? a : b; (compact replacement for single if-else).
  • = vs ==: = assigns; == tests equality. Always use str.equals("abc") for String content comparison!

5.3 Selection (if, switch) & Loops (for, while, do-while)

Java Selection and Loop Control Flow Structures Visual comparison of switch-case with break vs fall-through, entry-controlled for/while loops executing 0 or more times, and exit-controlled do-while loop executing at least 1 time. switch(expr) Selection • Tests equality on byte, short, int, char • Needs unique constant case labels • Missing break causes FALL-THROUGH! • Optional default handles non-matches switch(day){ case 1: ... break; } for & while (Entry-Controlled) • Condition checked BEFORE loop body • Minimum executions = 0 times • for(init; cond; upd) best for fixed count • while(cond) best for unknown count for(int i=1; i<=10; i++) sum+=i; do-while (Exit-Controlled) • Condition checked AFTER loop body • Minimum executions = 1 time • Trailing semicolon (;) is MANDATORY! • break exits loop; continue skips body do { ... } while(cond);
Figure 2.4: Selection (switch) & Entry- vs Exit-Controlled Loops (Ch 5, pp. 176–192).

5.4 Complete Worked Java Swing & Control-Flow Programs (Textbook Ch 5 Q4 a–l)

Every end-of-chapter program from the CHSE Odisha Class 11 IT syllabus (Ch 5, pp. 193–196) written with exact textbook slabs and conditions.

1. Q4(a–b) Swing Teacher ClassName ListBox & RadioButton Alignment Handler
// Q4(a) JList lstClass ("XI-A".."XI-D") -> Print Exact Class Teacher Name
String cls = (String) lstClass.getSelectedValue();
String teacher = "";
if ("XI-A".equals(cls))      teacher = "Ranjan Kumar Bal";
else if ("XI-B".equals(cls)) teacher = "Dhruba Charan Pradhan";
else if ("XI-C".equals(cls)) teacher = "N.C. Samal";
else if ("XI-D".equals(cls)) teacher = "Ajay Kumar Mishra";
txtTeacher.setText(teacher);

// Q4(b) JRadioButton Alignment inside ButtonGroup on "Set Alignment" JButton click
if (rdoLeft.isSelected())        btnTarget.setHorizontalAlignment(javax.swing.SwingConstants.LEFT);
else if (rdoCenter.isSelected()) btnTarget.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
else if (rdoRight.isSelected())  btnTarget.setHorizontalAlignment(javax.swing.SwingConstants.RIGHT);
2. Q4(c–e) Exact Electricity Bill (+ Rs. 250 Rent), Commission & Result Sheet
// Q4(c) Electricity Bill: First 100 @ 40P, Next 200 @ 60P, >300 @ Re.1 + Rs. 250.00 Rent
int units = Integer.parseInt(txtUnits.getText());
double charge;
if (units <= 100)       charge = units * 0.40;
else if (units <= 300)  charge = (100 * 0.40) + (units - 100) * 0.60;
else                    charge = (100 * 0.40) + (200 * 0.60) + (units - 300) * 1.00;
double netBill = charge + 250.00;
txtBill.setText(String.format("Rs. %.2f", netBill));

// Q4(d) Salesman Commission (<5000: 5%, 5000..10000: 8%, >10000: 10%)
double sales = Double.parseDouble(txtSales.getText());
double comm = (sales < 5000) ? sales * 0.05
            : (sales <= 10000) ? sales * 0.08 : sales * 0.10;

// Q4(e) Student Result Sheet (Print Formatted Mark Sheet & Grade)
int total = eng + it + math;
double pct = total / 3.0;
char grade = (pct < 50) ? 'D' : (pct < 60) ? 'C' : (pct < 80) ? 'B' : 'A';
System.out.println("NAME: " + name + "\nENGLISH MARKS: " + eng + "\nI.T. MARKS: " + it
  + "\nMATHS MARKS: " + math + "\nTOTAL MARKS = " + total + "\nPER CENT = " + pct + "\nGRADE = " + grade);
3. Q4(f–i) Leap Year, Quadratic Roots & switch-case Day / Month Name
// Q4(f) class leap
boolean isLeap = (year % 400 == 0) || (year % 4 == 0 && year % 100 != 0);
System.out.println(isLeap ? "LEAP YEAR" : "NOT A LEAP YEAR");

// Q4(g) Quadratic Equation ax^2 + bx + c = 0
double d = b * b - 4 * a * c;
if (d > 0) {
    double r1 = (-b + Math.sqrt(d)) / (2 * a);
    double r2 = (-b - Math.sqrt(d)) / (2 * a);
    System.out.println("REAL AND DISTINCT ROOTS: " + r1 + ", " + r2);
} else if (d == 0) {
    System.out.println("EQUAL ROOTS: " + (-b / (2 * a)));
} else {
    System.out.println("IMAGINARY ROOTS");
}

// Q4(h) Day Name via switch-case (similar for Month 1..12)
switch (day) {
    case 1: System.out.println("Sunday"); break;    case 2: System.out.println("Monday"); break;
    case 3: System.out.println("Tuesday"); break;   case 4: System.out.println("Wednesday"); break;
    case 5: System.out.println("Thursday"); break;  case 6: System.out.println("Friday"); break;
    case 7: System.out.println("Saturday"); break;
    default: System.out.println("Invalid Day Number (1-7)");
}
4. Q4(j–l) Cloth Showroom Discount, Income Tax Slab & Series Sums
// Q4(j) Cloth Showroom Festival Discount (char type: 'M' Mill Cloth, 'H' Handloom)
double discPct = 0;
switch (type) {
    case 'M': case 'm':
        if (amt < 1000) discPct = 2;
        else if (amt <= 5000) discPct = 20;
        else if (amt <= 10000) discPct = 40;
        else discPct = 50;
        break;
    case 'H': case 'h':
        if (amt < 1000) discPct = 5;
        else if (amt <= 5000) discPct = 25;
        else if (amt <= 10000) discPct = 50;
        else discPct = 60;
        break;
}
double netAmount = amt - (amt * discPct / 100.0);

// Q4(k) Employee Income Tax Slab
double tax = 0;
if (income <= 100000)       tax = 0;
else if (income <= 500000)  tax = 1000 + 0.10 * (income - 100000);
else if (income <= 800000)  tax = 5000 + 0.20 * (income - 500000);
else                        tax = 10000 + 0.30 * (income - 800000);

// Q4(l) Alternating & Odd Series Sums: (i) 2 - 4 + 6 - 8 + ... + 20   (ii) 1 + 3 + 5 + ... + 99
int s1 = 0, sign = 1;
for (int i = 2; i <= 20; i += 2) { s1 += sign * i; sign = -sign; } // s1 = -10
int s2 = 0;
for (int j = 1; j <= 99; j += 2) { s2 += j; }                      // s2 = 2500
CHSE Syllabus Unit Reference: Chapter 5: Programming Fundamentals (pp. 151–196)
Aligned with Odisha State Bureau Higher Secondary (+2) IT Part - I syllabus (Reference pp. 151+). All topic summaries, diagrams, and solved exercises are included directly on this page.
Chapter 6 • Official Bureau Syllabus

Programming Guidelines (Coding Style, Errors, 21 GUI Rules & 6 Stages)

4 Marks 10 Periods PDF pp. 197–210
11 Good Coding Guidelines
  • Use meaningful identifier names (totalMarks not x).
  • Write clear header & inline comments explaining non-obvious logic.
  • Maintain consistent indentation (2–4 spaces) and blank lines.
  • Prefer modular functions/methods (single task per module).
  • Keep expressions simple; avoid overly deep nesting or cryptic shortcuts.
  • Validate inputs, handle boundary/division-by-zero cases, avoid magic numbers.
3 Error Categories & Debugging
  • 1. Compile-Time Errors: Caught by javac before running — Syntax errors (missing ;, unmatched }) & Semantic errors (type mismatch, undeclared variable).
  • 2. Run-Time Errors: Crash program mid-execution (divide by zero, invalid parse input, null reference).
  • 3. Logical Errors: Compiles and runs cleanly, but gives wrong output (e.g., writing a + b / 2 instead of (a + b) / 2).
  • 3 Debugging Steps: (1) Locate error symptoms, (2) Isolate root cause via traces/breakpoints, (3) Fix & re-test.
6 Stages of GUI Application Development and Testing Matrix Six ordered stages from Analysis, Design, Coding, Testing and Debugging, Documentation, to Delivery and Maintenance, alongside Verification vs Validation and White-box vs Black-box testing. 6 Stages of GUI Application Development (PDF pp. 204–207) 1. Analysis Define problem & I/O 2. Design Form layout & algo 3. Coding Events & Java logic 4. Testing/Debug Fix syntax/logic bugs 5. Documentation User & tech manuals 6. Delivery & Maintenance Verification vs Validation • Verification: "Are we building the product RIGHT?" (design/code review) • Validation: "Are we building the RIGHT product?" (user requirements) White-Box vs Black-Box vs Unit Testing • White-Box: Inspects internal branches, loops & logic paths. • Black-Box: Tests inputs → outputs blindly; Unit: isolates 1 module.
Figure 2.5: 6 GUI Development Stages + Verification/Validation & Testing Types (Ch 6).
21 GUI Design Guidelines (Core Exam Summary): Know your users, ensure visual clarity, maintain consistent layout & fonts across forms, group related controls in JPanels, give clear error feedback (JOptionPane), use JRadioButton/JComboBox to prevent invalid typing errors, set logical Tab order, provide keyboard mnemonics, and avoid garish clashing colors.
CHSE Syllabus Unit Reference: Chapter 6: Programming Guidelines (pp. 197–210)
Aligned with Odisha State Bureau Higher Secondary (+2) IT Part - I syllabus (Reference pp. 197+). All topic summaries, diagrams, and solved exercises are included directly on this page.
Bureau Textbook Question Bank

Complete Solved Textbook Exercises — Chapters 4, 5 & 6

  • RAD (Rapid Application Development): ICU approach — Iterative development, Construction of working prototypes, Use of CASE tools/visual IDE like NetBeans.
  • Guarded Blocks: Grey-highlighted auto-generated NetBeans Swing code inside initComponents() that cannot be edited directly in Source view; modify via Design view or Properties panel.
  • Inspector Window: Displays tree hierarchy of both visual and non-visual components (like ButtonGroup) on the current form.
  • JCheckBox vs JRadioButton: Checkboxes permit zero, one, or multiple independent selections; RadioButtons inside a ButtonGroup enforce mutually exclusive single choice.
  • JComboBox vs JList: ComboBox opens as a compact drop-down (optionally editable); List shows multiple rows inside a scroll pane with single or multi-interval selection.
  • JPasswordField Method: Use getPassword() (returns char[]) rather than deprecated getText() for password security.
  • JOptionPane Confirm Constants: -1 = dialog closed via X, 0 = Yes/OK, 1 = No, 2 = Cancel.

  • MCQs (Q1 a–j): (a) JVM = Interpreter; (b) Platform independent = Yes; (c) Smallest integer = byte; (d) Non-primitive = enum; (e) int = 4 bytes; (f) Valid float = 1.23f; (g) boolean values = true & false; (h) Selection = if; (i) Incorrect String = \ Hello World (unescaped slash); (j) Default boolean = false.
  • VSA Conditionals (Q2 f–i): Check 'V' or 'y': if (var == 'V' || var == 'y'); Range 1500–2200: if (num >= 1500 && num <= 2200); Sum vs double b: if ((a + b) > 2 * b).
  • Output Traces (Q2 h, j, l & Q3 d):
    • Q2(h) firstName="Dhruba " + "Pradhan" → jTextField1 = "Full Name: ", jTextField2 = "Dhruba Pradhan".
    • Q2(j) Num = 6; Num = Num + 1; (7 > 5 is true) → jTextField1 = "7".
    • Q2(l) x=5; while(x<=36) x+=6; executes for x = 5, 11, 17, 23, 29, 35 → 6 times!
    • Q3(d)(i) For a=0: (0>0 && 0<20) is false, so else a--; runs → prints -1.
    • Q3(d)(ii) Corrected syntax if (a > b || a != b) c = ++a + --b;: if a=5, b=2 → c = 6 + 1 = 7 (761); if a=0, b=0 → if is false (c stays unchanged).
    • Q3(d)(iii) (x+y > x*2) ? x++ : y for x=5, y=3: 8 > 10 is false → prints 3!
    • Q3(d)(iv) For Income=225000: Income > 100000 is true → prints Income tax=Rs.22500.0.
  • Ch 4 VSA Trap: Learning.concat("Java") fails unless Learning is an initialized String variable; string literal "Learning".concat("Java") prints LearningJava.

  • 3 Steps of Problem Solving: (1) Analyze problem & I/O, (2) Design algorithm/flowchart/UI, (3) Code, test & document solution.
  • Syntax vs Logical Error: Missing semicolon prevents compilation (Syntax error caught by javac); using wrong formula like P*R*T instead of (P*R*T)/100 produces wrong output at runtime (Logical error).
  • Top-Down vs Bottom-Up: Top-down decomposes main task into sub-modules first; Bottom-up builds & tests reusable leaf components first and combines upward.
  • Verification vs Validation & White-Box vs Black-Box: See Infographic 2.5 above for exam-ready definitions.

Unit 2 Board Exam Practice Quiz (10 Questions)

Click any option to verify your CHSE exam readiness instantly.
Score: 0 / 10
Q1. What keyboard shortcut runs the currently open Swing form/Java file directly in NetBeans IDE?
Answer Explanation: In NetBeans IDE, Shift+F6 compiles and runs the currently active file, whereas F6 runs the main project.
Q2. Which Swing non-visual helper forces multiple JRadioButtons to allow only one active selection?
Answer Explanation: ButtonGroup logically links JRadioButtons (visible in the NetBeans Inspector window) so selecting one deselects others.
Q3. What integer value is returned by JOptionPane.showConfirmDialog() if the user clicks "Yes" or "OK"?
Answer Explanation: JOptionPane constants return: 0 (Yes/OK), 1 (No), 2 (Cancel), and -1 if closed without clicking a button.
Q4. Which Swing components allow lightweight OS-independent Pluggable Look and Feel (PLAF)?
Answer Explanation: Swing components (javax.swing) are lightweight 100% Java widgets supporting PLAF, unlike OS-dependent heavyweight AWT.
Q5. Which Java method converts user input "450" from a JTextField into an integer for calculation?
Answer Explanation: Integer.parseInt(str) parses numeric text into primitive int; Double.parseDouble(str) converts decimal strings.
Q6. What happens in a Java switch statement if a matching case omits the break; statement?
Answer Explanation: Omitting break causes fall-through execution into subsequent case blocks until a break or closing brace is reached.
Q7. Which Java loop guarantees execution of its body at least once even if the condition is initially false?
Answer Explanation: do-while is an exit-controlled loop that executes the body first and checks the condition afterward (with a trailing semicolon).
Q8. Writing "avg = a + b / 2;" instead of "(a + b) / 2" is an example of which error?
Answer Explanation: The statement compiles and runs without crashing, so javac sees no syntax/semantic error; it is a Logical error producing an incorrect average.
Q9. In the 6 Stages of GUI Development, which stage immediately follows Coding?
Answer Explanation: The 6 ordered stages are: 1. Analysis -> 2. Design -> 3. Coding -> 4. Testing & Debugging -> 5. Documentation -> 6. Delivery & Maintenance.
Q10. Which testing checks "Are we building the right system" against real user requirements?
Answer Explanation: Validation confirms the finished product satisfies actual user requirements; Verification confirms each phase follows specs.