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 (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, ladderelse if,switch(int/char)+breakfall-through - Loops: Entry-controlled
for&while(0+ runs) vs Exit-controlleddo-while(at least 1 run) - Jumps:
break(exits loop/switch) vscontinue(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
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
JDK Core Tools (PDF p. 108)
javac: Java Compiler (.java→.classbytecode).java: Java Application Launcher / JVM Interpreter.javadoc: Generates HTML API docs from/** ... */comments.jar: Packages classes/resources into compressed.jararchive.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), prefixJ(e.g.,JButton). - Event Handling (Delegation Model): Event (
ActionEvent/click) → Event Source (JButton) → Event Listener (ActionListenerrunningactionPerformed(evt)).
4.2 Complete Swing Controls, Properties & Methods Reference (pp. 122–146)
| Swing Control | Purpose / Behavior | Key Properties & Common Java Methods |
|---|---|---|
JLabel | Displays non-editable read-only text or icon. | text, font, foreground, background, enabled, toolTipText; getText(), setText(str), setEnabled(), setToolTipText() |
JTextField | Single-line editable text box (read-only if editable=false). | text, editable, font, foreground, background, enabled, toolTipText; getText(), setText(str), setEditable(bool), setEnabled(), setToolTipText() |
JTextArea | Multi-line text box inside a JScrollPane. | rows, columns, lineWrap, editable; append(str), getText(), setText(str) |
JButton | Triggers an action on click via ActionListener. | text, label, font, foreground, background, enabled, mnemonic; getText(), setText(str), doClick(), setEnabled(bool) |
JCheckBox | Square toggle allowing multiple independent selections. | selected, text, label, font, foreground, buttonGroup; isSelected(), setSelected(bool), getText(), setText() |
JRadioButton | Round option button inside a ButtonGroup for mutually exclusive choice. | buttonGroup, selected, text, label, font, background, foreground, enabled; isSelected(), setSelected(bool), getText(), setText() |
ButtonGroup | Non-visual container ensuring only 1 radio button in group is selected. | Visible in NetBeans Inspector window; add(), getSelection(), clearSelection() |
JComboBox | Drop-down list + optional editable text field (saves form space). | model, editable, enabled, background, buttonGroup; getSelectedItem(), getSelectedIndex(), setModel(), addItem() |
JList | Scrollable vertical list supporting Single or Multiple interval selection. | model, selectedIndex, selectedItem, selectionMode, font, enabled; getSelectedValue(), getSelectedIndex(), getSelectedValuesList() |
JPasswordField | Masks keystrokes using echoChar (default */bullet). | echoChar, editable, font; getPassword() returns char[] (new String(pf.getPassword())) |
JOptionPane / DefaultTableModel | Modal 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):
- Click File → New Project → Java → Java Application → Finish.
- Right-click package → New → JFrame Form → switch between Design and Source tabs.
- Drag
JLabel,JTextField,JRadioButton/ButtonGroup, andJButtonfrom Palette onto the Design canvas. - Right-click each widget → Change Variable Name (e.g.,
txtUnits,btnCalc) and configure text/font in Properties. - Double-click the button (or right-click → Events → Action → actionPerformed) to write Java code inside the editable body below Guarded Blocks.
- Press
Shift + F6to 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.
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).
5.2 Java Operators & Precedence Exam Rules
- Prefix vs Postfix (
++avsa++): Prefix changes value first then uses it; Postfix uses existing value in expression then increments/decrements. - Integer Division Trap:
7 / 2 == 3(bothint), whereas7.0 / 2 == 3.5(widened todouble). Modulo%keeps dividend sign (7 % 2 == 1). - Ternary Operator:
max = (a > b) ? a : b;(compact replacement for singleif-else). =vs==:=assigns;==tests equality. Always usestr.equals("abc")forStringcontent comparison!
5.3 Selection (if, switch) & Loops (for, while, do-while)
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.
11 Good Coding Guidelines
- Use meaningful identifier names (
totalMarksnotx). - 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
javacbefore 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 / 2instead of(a + b) / 2). - 3 Debugging Steps: (1) Locate error symptoms, (2) Isolate root cause via traces/breakpoints, (3) Fix & re-test.
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.
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
ButtonGroupenforce 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()(returnschar[]) rather than deprecatedgetText()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)booleanvalues =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 > 5is true) →jTextField1="7".Q2(l)x=5; while(x<=36) x+=6;executes forx = 5, 11, 17, 23, 29, 35→ 6 times!Q3(d)(i)Fora=0:(0>0 && 0<20)is false, soelse a--;runs → prints-1.Q3(d)(ii)Corrected syntaxif (a > b || a != b) c = ++a + --b;: ifa=5, b=2→c = 6 + 1 = 7(761); ifa=0, b=0→ifis false (cstays unchanged).Q3(d)(iii)(x+y > x*2) ? x++ : yforx=5, y=3:8 > 10is false → prints3!Q3(d)(iv)ForIncome=225000:Income > 100000is true → printsIncome tax=Rs.22500.0.
- Ch 4 VSA Trap:
Learning.concat("Java")fails unlessLearningis an initialized String variable; string literal"Learning".concat("Java")printsLearningJava.
- 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 likeP*R*Tinstead of(P*R*T)/100produces 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.
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.
Previous
Unit 1: Computer Systems (25M)
Master Syllabus
1st Year Mindmap & Hub
Next
Unit 3: RDBMS & MySQL (15M)
Discussion & Queries 0
Post a Comment or Doubt