Unit 2 • 16 Marks / 40 Periods

Programming Fundamentals & HTML

Comprehensive CHSE notes covering Object-Oriented Programming in Java (Classes, Inheritance, String/Math), JDBC/ODBC, HTML tags, Forms, DHTML, and an introduction to XML.

Programming Fundamentals in Java

1. Review: Java Basics

A quick recap of basic concepts (originally covered in 1st Year):

  • Variables & Data Types: Primitives include int, float, double, char, boolean. A variable is a named memory location.
  • Operators: Arithmetic (+, -, *, /, %), Relational (==, !=, >, <), Logical (&&, ||, !), and Assignment (=).
  • Control Structures:
    • Conditional: if/else, switch.
    • Looping: for, while, do-while.

2. Access Specifiers (Modifiers)

Definition: Access specifiers are keywords in Object-Oriented Programming that control the visibility or accessibility of class members (variables and methods) from other parts of a program.

There are four access specifiers in Java:

  1. public: Accessible from anywhere. It has the widest scope (same class, same package, subclass, different package).
  2. private: Accessible only within the same class. Used for data hiding and encapsulation.
  3. protected: Accessible within the same class, same package, and by subclasses (even if the subclass is in a different package). Vital for inheritance.
  4. default (Package-Private): When no keyword is specified. Accessible only within classes of the same package.
Comparison of Access Specifiers
Access Specifier Same Class Same Package Subclass (Different Package) Different Package
public Yes Yes Yes Yes
protected Yes Yes Yes No
default (no modifier) Yes Yes No No
private Yes No No No

3. Classes and Objects

Class: A blueprint or template that defines the attributes (data members) and behaviors (methods) of an entity.

Object: An instance of a class. It is the actual physical or logical entity occupying memory.

class Student {
    private int rollno;     // private data member
    String name;            // default access
    public int marks;       // public data member
    
    public void display() { // public method
        System.out.println(rollno + " " + name + " " + marks);
    }
}

// Creating an object:
Student s1 = new Student();
s1.name = "Rohan";
s1.marks = 90;
s1.display();
  • Constructor: A special method with the exact same name as the class and no return type. It is called automatically when an object is created to initialize it.
    • Default Constructor: Created by Java if no constructor is explicitly defined.
    • Parameterized Constructor: Takes parameters to initialize an object with specific values.
  • this keyword: Refers to the current object invoking the method or constructor. Helpful in resolving naming collisions between instance variables and parameters.

4. Encapsulation

Definition: The mechanism of wrapping data (variables) and code acting on that data (methods) together as a single unit (class). It is the basis for data hiding.

  • Data Hiding: Achieved by declaring class variables as private.
  • Getter Methods: A public method used to read the value of a private variable (e.g., getRollno()).
  • Setter Methods: A public method used to write/update the value of a private variable (e.g., setRollno(int r)).
Benefit of Encapsulation: It allows you to maintain control over the data, adding validation logic in setters, and flexibility to change internal implementations without affecting other parts of the code.

5. Inheritance

Definition: The mechanism by which one class acquires the properties and methods of another class. It promotes the "IS-A" relationship and enables code reusability.

  • Superclass (Parent class): The class whose properties are inherited.
  • Subclass (Child class): The class that inherits. It uses the extends keyword.
class Animal {                // Superclass
    String name;
    public void eat() { 
        System.out.println("Eating..."); 
    }
}
class Dog extends Animal {    // Subclass
    public void bark() { 
        System.out.println("Woof!"); 
    }
}
// Dog object uses inherited and own methods:
Dog d = new Dog();
d.eat();   // Inherited from Animal
d.bark();  // Own method

Types of Inheritance in Java:

  1. Single Inheritance: Class B extends Class A.
  2. Multilevel Inheritance: Class C extends Class B, which extends Class A.
  3. Hierarchical Inheritance: Class B and Class C both extend Class A.
  4. Multiple Inheritance: NOT supported directly in Java for classes to prevent ambiguity (the Diamond Problem). It is implemented using interfaces instead.
  • Method Overriding: When a subclass redefines a method present in the superclass with the exact same signature (name and parameters). Usually denoted with the @Override annotation.
  • super keyword: Used to refer to the immediate parent class object.
    • super() invokes the parent class constructor.
    • super.method() calls a parent class method.

6. Commonly Used Java Libraries

a) String Class Methods (java.lang.String)

Strings in Java are objects and are immutable (cannot be changed once created).

Method Syntax Description Example
toString() Returns the string representation of an object. Integer.toString(42) → "42"
concat(String s) Appends s to the end of the string. "Next".concat("Note") → "NextNote"
length() Returns total number of characters. "CHSE".length() → 4
toLowerCase() Converts all characters to lowercase. "ODISHA".toLowerCase() → "odisha"
toUpperCase() Converts all characters to uppercase. "java".toUpperCase() → "JAVA"
trim() Removes leading and trailing whitespace. " Exam ".trim() → "Exam"
substring(int beginIndex) Returns substring from beginIndex to end. "Information".substring(4) → "rmation"
substring(int begin, int end) Returns substring from begin to (end - 1). "Information".substring(0, 4) → "Info"
charAt(int index) Returns character at the specified index. "HTML".charAt(1) → 'T'
equals(String s) Checks content equality (case-sensitive). "A".equals("a") → false

Other notable string methods: indexOf(String s), equalsIgnoreCase(String s), replace(old, new), contains(String s), startsWith(s) / endsWith(s).

b) Math Class Methods (java.lang.Math)

  • Math.pow(double base, double exponent): Returns the value of the base raised to the power of the exponent.
    Example: Math.pow(2, 3) returns 8.0
  • Math.round(double a): Rounds the argument to the nearest whole integer (returns a long).
    Example: Math.round(3.7) returns 4. Math.round(3.4) returns 3.
  • Other methods: Math.sqrt(n) (square root), Math.abs(n) (absolute positive value), Math.max(a,b), Math.min(a,b).

7. Accessing Database using JDBC/ODBC

Feature ODBC (Open Database Connectivity) JDBC (Java Database Connectivity)
Definition Microsoft standard API for connecting to databases. Java API (in java.sql package) specifically for Java programs.
Language Dependency Language independent, mainly used for C/C++ on Windows. Platform independent, strictly for Java applications.
Drivers Requires OS-level database specific ODBC driver. Requires database specific JDBC driver (usually a .jar file).

Steps for JDBC Connection in Java:

  1. Load the Driver: Class.forName("com.mysql.cj.jdbc.Driver");
  2. Establish Connection: Connection con = DriverManager.getConnection("jdbc:mysql://localhost:3306/db_name", "user", "pass");
  3. Create Statement: Statement stmt = con.createStatement();
  4. Execute Query: ResultSet rs = stmt.executeQuery("SELECT * FROM student");
  5. Process Results: Loop through using while(rs.next()) { ... }
  6. Close Connection: rs.close(); stmt.close(); con.close();
PreparedStatement vs Statement: A PreparedStatement allows pre-compiled SQL queries with ? placeholders. It offers better performance and prevents SQL Injection attacks.

HTML Based Web Pages

1. Introduction to HTML

HTML (HyperText Markup Language) is a markup language used for creating and structuring web pages. It is NOT a programming language (it lacks logic like loops and if/else).

  • Uses tags wrapped in angle brackets: <tagname>content</tagname>.
  • It is case-insensitive, but lowercase is recommended (standard in HTML5).
  • Attributes provide additional information and are written as key="value" inside the opening tag.

2. Basic HTML Document Structure

<!DOCTYPE html>          <!-- HTML5 Document declaration -->
<html lang="en">         <!-- Root element -->
<head>                   <!-- Metadata section (invisible) -->
    <title>Page Title</title>
    <meta charset="UTF-8">
</head>
<body>                   <!-- Visible page content goes here -->
    <h1>Welcome</h1>
</body>
</html>

3. Text Formatting Tags

Tag Purpose
<h1> to <h6>Headings. h1 is the largest/most important; h6 is the smallest. Only use one h1 per page.
<p>Paragraph. Adds top and bottom margin automatically.
<br>Line break. It is a self-closing (empty) tag.
<hr>Horizontal rule (separator line). Attributes: width, size, color.
<b> / <strong>Bold text. (Strong implies high importance semantically).
<i> / <em>Italicized text. (Em implies emphasis semantically).
<u>Underlined text.
<sub> / <sup>Subscript (H2O) and Superscript (x2).
<pre>Preformatted text. Preserves whitespace, line breaks, uses a monospace font.

4. Font Tag (Legacy)

The <font> tag is used to change text appearance. Note: Deprecated in modern HTML in favor of CSS.

Syntax: <font face="Arial" size="4" color="red">Text</font>

  • face: The font family name.
  • size: Values range from 1 to 7.
  • color: Named color or hex code (#FF0000).

5. Hyperlinks and Images

Links (Anchor Tag): <a href="URL">Click Here</a>

  • href: Specifies the destination URL (absolute or relative path).
  • target="_blank": Opens the link in a new tab.
  • mailto: Used for emails (e.g., href="mailto:[email protected]").

Images: <img src="image.jpg" alt="Description" width="300" height="200">

  • src: The path to the image file.
  • alt: Alternative text displayed if the image fails to load (essential for accessibility and SEO).
  • The img tag is self-closing; no </img> required.

6. Tables

Tables are created using the <table> element.

  • <tr>: Defines a table row.
  • <th>: Defines a header cell (bold and centered by default).
  • <td>: Defines a standard data cell.
  • colspan / rowspan: Attributes used to merge columns or rows respectively.
  • <caption>: Sets the title of the table.

7. HTML Lists

  1. Unordered List (<ul>): Displays items with bullets.
    Attribute: type="disc|circle|square"
  2. Ordered List (<ol>): Displays items with numbers/letters.
    Attributes: type="1|A|a|I|i", start="number".
  3. Definition List (<dl>): A dictionary-like list. Uses <dt> for the term and <dd> for the description.

8. HTML Forms

The <form> element collects user input. Key form attributes:

  • action: The URL of the script that processes the form submission (e.g., "submit.php").
  • method: Specifies how to send form data.
GET vs POST Method
Feature GET Method POST Method
Data Visibility Data appended to URL (visible to everyone). Data sent inside the HTTP body (hidden).
Security Low (Not for passwords or sensitive data). High (Suitable for sensitive data).
Data Limit Limited (approx. 2000 characters). No size restrictions.
Usage Safe for searching/retrieving data. Used for updating, inserting, or file uploads.

Important Form Controls:

  • <input type="text">: Single-line text.
  • <input type="password">: Masks typed characters.
  • <input type="radio">: Radio button. Mutually exclusive selection (ensure they share the same name).
  • <input type="checkbox">: Multiple selection boxes.
  • <textarea rows="5" cols="40"></textarea>: Multi-line text field.
  • <select> & <option>: Creates a dropdown list.
  • <input type="submit"> & <input type="reset">: Buttons to send or clear data.
  • <input type="hidden">: Stores data invisibly to be sent to the server.

9. DHTML (Dynamic HTML)

DHTML is not a language but a combination of technologies—HTML, CSS, and JavaScript—used to create interactive and animated web sites.

  • It modifies the page content dynamically without reloading the page.
  • DOM (Document Object Model): JavaScript uses the DOM tree to access and alter elements.
    Example: document.getElementById("myText").innerHTML = "Hello";
  • Event Handlers: JavaScript functions triggered by user actions. Examples: onclick, onmouseover, onmouseout, onkeyup, onload.

10. XML (Extensible Markup Language)

XML is designed to store and transport data, unlike HTML which is designed to present data.

  • It is self-descriptive and uses user-defined tags (you invent your own tags like <student>).
  • Well-formed XML Rules:
    1. Must have exactly one root element.
    2. All tags must be properly closed and properly nested.
    3. Tags are strictly case-sensitive.
    4. Attribute values must always be enclosed in quotes.
HTML vs XML Comparison
HTML XML
Used for formatting and displaying data. Used for storing and transporting data.
Has predefined tags (e.g., <p>, <table>). Has user-defined tags (extensible).
Case-insensitive. Strictly case-sensitive.
Lax syntax (unclosed tags sometimes work). Strict syntax (must be "well-formed").

Key Exam Points (Unit 2)

  • The default access specifier is applied when no keyword is used; it allows package-level access.
  • Multiple inheritance in Java is NOT supported for classes to avoid the diamond problem. It is achieved via Interfaces.
  • this refers to the current object, while super refers to the parent class object.
  • String methods substring(start, end) stops at end - 1. Example: substring(0,3) on "CHSE" returns "CHS".
  • Math.round(4.5) returns 5, whereas Math.round(4.4) returns 4. Result type is long.
  • JDBC prevents SQL injection by utilizing PreparedStatement over regular Statement.
  • HTML is a markup language, not a programming language. It doesn't contain logical operators.
  • The alt attribute in <img> is compulsory for accessibility and broken links.
  • colspan merges columns (horizontally), rowspan merges rows (vertically).
  • A form GET method appends data to the URL. Use POST for sensitive/large data.
  • Radio buttons must share the exact same name attribute to be mutually exclusive.
  • A well-formed XML document strictly requires one single root element and case-sensitive matching tags.

Official CHSE Odisha IT Question Bank — Unit 2 Solved Paper

Complete exam-oriented solutions (Paper-I & Paper-II) with textbook errata corrections for Class 12 Board Exams.
Full Printable Solved Paper (372 Qs)
103 Total Solved Q&As 83 Paper-I (MCQ / Blanks / 1M) 17 Paper-II Objective 3 Long Board Subjective

Paper-II Full Long Subjective Answers (CHSE Board Pattern)

Paper II · Unit 2 Board Subjective (5–7M)
Q1. Explain the use of five commonly used tags in an HTML document.
CHSE Exam-Oriented Model Answer:

Below are five fundamental HTML tags with syntax and clear exam explanations:

  1. <html>...</html> (Root Tag): Encloses the entire HTML web page document. Browser treats everything inside as HTML markup.
  2. <head>...</head> (Document Header): Contains metadata not rendered directly in the viewport (<title>, <meta>, <style>).
  3. <title>...</title> (Page Title): Sets the document title displayed in the browser tab bar and search engine bookmarks.
  4. <body>...</body> (Document Body): Holds all visible page elements — headings, paragraphs, images, tables, forms, and links.
  5. <p>...</p> (Paragraph Tag): Formats blocks of prose text with automatic vertical spacing before and after each paragraph.
<html>
  <head><title>CHSE Odisha Class 12 IT</title></head>
  <body bgcolor="#f8fafc">
    <h1>Welcome Students</h1>
    <p>This is a complete HTML document structure.</p>
  </body>
</html>
Paper II · Unit 2 Board Subjective (5–7M)
Q2. What is meant by Access Modifier? Describe the uses of different Access Modifiers of Java with examples
CHSE Exam-Oriented Model Answer:

Definition: Access Modifiers (Specifiers) in Java control who can access a class, constructor, variable, or method, enforcing encapsulation and data hiding.

ModifierSame ClassSame PackageSubclass (Diff Pkg)World / Everywhere
privateYesNoNoNo
default (none)YesYesNoNo
protectedYesYesYes (via inheritance)No
publicYesYesYesYes
package school;
public class Student {
    private int secretPin = 1234;   // only inside Student
    int rollNo = 101;               // default: package school only
    protected String grade = "A+";  // school + external subclasses
    public String name = "Aarav";   // accessible anywhere
}
Paper II · Unit 2 Board Subjective (5–7M)
Q3. What are the different types of inheritance in Java?
CHSE Exam-Oriented Model Answer:

Inheritance allows a child class (subclass) to acquire fields and methods of an existing parent class (superclass) using the extends keyword, promoting code reusability.

  • 1. Single Inheritance: One subclass inherits from one superclass (A → B). Example: class Dog extends Animal {}.
  • 2. Multilevel Inheritance: A chain of inheritance (A → B → C). Example: Vehicle → Car → ElectricCar.
  • 3. Hierarchical Inheritance: Multiple subclasses share one common parent (A → B and A → C).
  • 4. Multiple & 5. Hybrid Inheritance (via Interfaces only): Java prohibits multiple class inheritance (to avoid the diamond ambiguity), so classes achieve multiple/hybrid inheritance by implementing multiple interfaces via implements.
class Animal { void eat() { System.out.println("Eating..."); } }
class Dog extends Animal { void bark() { System.out.println("Barking"); } } // Single
class Puppy extends Dog { void weep() { System.out.println("Weeping"); } } // Multilevel
Solved Paper-I Workbook Questions — MCQs, Blanks & 1-Mark (83 Qs) Click to Toggle
Paper I · Unit 2 MCQ (1M)
Q1. What happens if constructor of class A is made private?
(a) Any class can instantiate objects of class A
(b) Objects of class A can be instantiated only within the class where it is declared
(c) Inherited class can instantiate objects of class A
(d) classes within the same package as class A can instantiate objects of class A
Answer: (b) Objects of class A can be instantiated only within the class where it is declared
Exam Concept: A private constructor blocks external new A() instantiation (used in Singleton / utility classes).
Paper I · Unit 2 MCQ (1M)
Q2. All the variables of interface should be ?
(a) default and final
(b) default and static
(c) public, static and final
(d) protect, static and final
Answer: (c) public, static and final
Exam Concept: In Java, every field declared inside an interface is implicitly public, static, and final (a class constant).
Paper I · Unit 2 MCQ (1M)
Q3. What is true of final class?
(a) Final class cause compilation failure
(b) Final class cannot be instantiated
(c) Final class cause runtime failure
(d) Final class cannot be inherited
Answer: (d) Final class cannot be inherited
Exam Concept: Adding the final keyword to a class declaration (e.g., final class String) prevents any subclass from extending it.
Paper I · Unit 2 MCQ (1M)
Q4. Which inheritance in java programming is not supported?
(a) Multiple inheritance using classes
(b) Multiple inheritance using interfaces
(c) Multilevel inheritance
(d) Single inheritance
Answer: (a) Multiple inheritance using classes
Exam Concept: Java forbids a class extending more than one superclass to prevent the Diamond Ambiguity problem; multiple inheritance is supported via Interfaces.
Paper I · Unit 2 MCQ (1M)
Q5. What is subclass in java?
(a) Subclass is a class that extends another class
(b) Subclass is a class declared inside a class
(c) Both above
(d) None of the above
Answer: (a) Subclass is a class that extends another class
Exam Concept: A subclass (child/derived class) inherits non-private fields and methods of a superclass using extends.
Paper I · Unit 2 MCQ (1M)
Q6. If class B is sub classed from class A then which is the correct syntax
(a) Class B: A {}
(b) Class B extends A {}
(c) Class B extends class A {}
(d) Class B implements A {}
Answer: (b) Class B extends A {} (with lowercase class)
Exam Concept: Java uses the extends keyword for class-to-class inheritance (implements is only for interfaces).
Paper I · Unit 2 MCQ (1M)
Q7. Order of execution of constructors in Java Inheritance is
(a) Base to derived class
(b) Derived to base class
(c) Random order
(d) None
Answer: (a) Base to derived class
Exam Concept: Java invokes the parent superclass constructor (super()) first so base fields are initialized before the subclass constructor executes.
Paper I · Unit 2 MCQ (1M)
Q8. Inheritance relationship in Java language is
(a) Association
(b) Is-A
(c) Has-A
(d) None
Answer: (b) Is-A
Exam Concept: Inheritance establishes an "Is-A" relationship (e.g., Car Is-A Vehicle), whereas Composition creates a "Has-A" relationship.
Paper I · Unit 2 MCQ (1M)
Q9. Advantage of inheritance in java programming is/are
(a) Code Re-usability
(b) Class Extendibility
(c) Save development time
(d) All
Answer: (d) All
Exam Concept: Inheritance avoids rewriting common superclass logic, lets developers specialize behavior, and speeds up coding.
Paper I · Unit 2 MCQ (1M)
Q10. Which of the following is/are true statements?
(a) A class can extend only one class but can implement many interfaces
(b) An interface can extend many interfaces
(c) An interface can implement another interface
(d) An interface can implement a class
Answer: (a) & (b) Both A and B are true
Exam Concept: A class uses extends once + implements zero or more interfaces; an interface uses extends for parent interfaces.
Paper I · Unit 2 MCQ (1M)
Q11. Which class cannot be sub classed?
(a) final class
(b) object class
(c) abstract class
(d) child class
Answer: (a) final class
Exam Concept: A final class forbids inheritance; abstract and Object classes are specifically designed to be subclassed.
Paper I · Unit 2 MCQ (1M)
Q12. Which is/are false statements
(a) final class cannot be inherited
(b) final method can be inherited
(c) final method can be overridden
(d) Final variable of a class cannot be changed.
Answer: (c) final method can be overridden (False statement)
Exam Concept: A final method CAN be inherited by child classes, but CANNOT be overridden by any subclass.
Paper I · Unit 2 MCQ (1M)
Q13. Which cannot be inherited from a base class in Java programming
(a) Constructor
(b) final method
(c) Both
(d) None
Answer: (a) Constructor
Exam Concept: Constructors belong solely to their declaring class and are never inherited (subclasses call them via super()).
Paper I · Unit 2 MCQ (1M) Erratum Fixed
Q14. Which cannot be inherited / Which statements are valid for base-class methods in Java programming? [Workbook Q14 repeats header; key picks (d) All]
(a) Cannot override private method of a class
(b) Protected methods are visible to only immediate child class
(c) Public methods of a class are visible to all
(d) All
Answer: (d) All
Exam Concept: Private methods are invisible to subclasses so they cannot be overridden; public methods are accessible everywhere.
Workbook Key Note / Correction: Workbook PDF misprints the Q13 stem ("Which cannot be inherited...") above options about overriding/visibility; technically (a) and (c) are true while (b) is imprecise (protected is visible across the entire package AND all subclasses). Workbook key selects (d) All.
Paper I · Unit 2 MCQ (1M)
Q15. To prevent a class to be inherited / extended, the class should be
(a) final class
(b) abstract class
(c) final and abstract both
(d) none
Answer: (a) final class
Exam Concept: Declaring a class final stops all subclassing (final and abstract cannot even be combined on a class!).
Paper I · Unit 2 MCQ (1M)
Q16. Which of these class is superclass of every class in Java?
(a) String class
(b) Object class
(c) Abstract class
(d) ArrayList class
Answer: (b) Object class
Exam Concept: java.lang.Object sits at the root of Java’s class hierarchy; every class inherits directly or indirectly from Object.
Paper I · Unit 2 MCQ (1M) Erratum Fixed
Q17. Which of these method of Object class can clone an object?
(a) ObjectCopy ()
(b) Copy ()
(c) Objectclone ()
(d) Clone ()
Answer: (d) clone() [Workbook key prints (c) Objectclone ()]
Exam Concept: Classes implementing Cloneable override Object.clone() to duplicate object fields.
Workbook Key Note / Correction: Exact Java API method on java.lang.Object is protected clone() (closest option is (d) with lowercase c). Workbook key mistakenly prints (c) Objectclone ().
Paper I · Unit 2 MCQ (1M)
Q18. Which of these keywords can be used to prevent inheritance of a class?
(a) Super
(b) Constant
(c) Class
(d) Final
Answer: (d) final
Exam Concept: The final keyword stops class inheritance, method overriding, and variable reassignment.
Paper I · Unit 2 MCQ (1M)
Q19. Which of these class relies upon its subclasses for complete implementation of its methods?
(a) Object class
(b) Abstract class
(c) ArrayList class
(d) None of these
Answer: (b) Abstract class
Exam Concept: An abstract class declares abstract methods (without body) that concrete subclasses must implement.
Paper I · Unit 2 MCQ (1M)
Q20. If a class inheriting an abstract class does not define all of its function then it will be known as?
(a) Abstract Class
(b) Simple Class
(c) Static class
(d) None of these
Answer: (a) Abstract Class
Exam Concept: Any subclass leaving even one inherited abstract method unimplemented must itself be marked abstract.
Paper I · Unit 2 Fill in Blank / T-F Erratum Fixed
Q21. Method to compare two strings ignoring the case is ________
Answer: equalsIgnoreCase() [Workbook typo: equalsIgoreCase()]
Exam Concept: Example: "CHSE".equalsIgnoreCase("chse") returns true.
Workbook Key Note / Correction: Workbook key omits "n" (equalsIgoreCase()). In Java exams always write exact spelling: equalsIgnoreCase().
Paper I · Unit 2 Fill in Blank / T-F
Q22. ________ method converts an entire string to Upper case.
Answer: toUpperCase()
Exam Concept: Example: "odisha".toUpperCase() returns "ODISHA".
Paper I · Unit 2 Fill in Blank / T-F
Q23. ________ Method Removes spaces from both sides of a String.
Answer: trim()
Exam Concept: Example: " Java ".trim() returns "Java".
Paper I · Unit 2 Fill in Blank / T-F
Q24. ________ Returns absolute value of the number.
Answer: abs() [Math.abs()]
Exam Concept: Math.abs(-15) returns 15.
Paper I · Unit 2 Objective / Short (1–2M)
Q25. What is a method that compares two strings and supports a 3-way comparison?
Answer: compareTo()
Exam Concept: s1.compareTo(s2) returns < 0 if s1 < s2, 0 if equal, and > 0 if s1 > s2 (lexicographical Unicode comparison).
Paper I · Unit 2 Objective / Short (1–2M)
Q26. What is a method that compares two strings and supports 2-way comparison?
Answer: equals()
Exam Concept: s1.equals(s2) returns boolean true or false (strict case-sensitive character match).
Paper I · Unit 2 Objective / Short (1–2M)
Q27. Which method concatenates two strings / Joins two strings?
Answer: concat()
Exam Concept: "Hello ".concat("IT") returns "Hello IT".
Paper I · Unit 2 Objective / Short (1–2M)
Q28. Which Method Returns a character by index position in a string?
Answer: charAt()
Exam Concept: Zero-indexed: "CHSE".charAt(1) returns 'H'.
Paper I · Unit 2 Objective / Short (1–2M)
Q29. Method to return part of a string in java.
Answer: substring()
Exam Concept: Supports substring(startIndex) and substring(startIndex, endIndex) (stops at endIndex - 1).
Paper I · Unit 2 Objective / Short (1–2M)
Q30. A Method that returns a Boolean value to check a string with specified suffix.
Answer: endsWith()
Exam Concept: Example: "notes.pdf".endsWith(".pdf") returns true (startsWith() checks prefixes).
Paper I · Unit 2 Objective / Short (1–2M)
Q31. What will be the output of the code? Integer a = 5; println(a.compareTo(5)); println(a.compareTo(6)); println(a.compareTo(4));
Answer: 0
-1
1
Exam Concept: 5 == 5 prints 0; 5 < 6 prints -1; 5 > 4 prints 1.
Paper I · Unit 2 Objective / Short (1–2M)
Q32. How can a protected modifier be accessed?
Answer: Within the same package (any class) AND outside the package via inheritance (subclasses only).
Exam Concept: Workbook key prints short phrase "within package"; always include "and subclasses outside the package" for full board marks.
Paper I · Unit 2 Objective / Short (1–2M)
Q33. How many copies of static and instance (class-member) variables are created when 10 objects are created of a class?
Answer: 1 copy of static variable (shared by class) and 10 copies of instance (non-static) variables — i.e., 1, 10.
Exam Concept: Note: Java often calls static variables "class variables" and non-static fields "instance variables"; 1, 10 means 1 shared static copy and 10 per-object instance copies.
Paper I · Unit 2 Question
Q34. A top-level class can be declared with a protected modifier. State True/False
Answer: False
Exam Concept: Top-level Java classes only allow public or package-private (default), never protected or private (only nested inner classes allow protected/private).
Paper I · Unit 2 Objective / Short (1–2M)
Q35. Which is the modifier when there is none mentioned explicitly?
Answer: Default (Package-Private)
Exam Concept: With no modifier keyword written, members are accessible only to classes within the same package.
Paper I · Unit 2 MCQ (1M)
Q1. Which of the following tag is used for line breaks in the documents?
(a) <p>
(b) <br>
(c) <hr>
(d) <break>
Answer: (b) <br>
Exam Concept: <br> is an empty/void tag that inserts a single line break.
Paper I · Unit 2 MCQ (1M)
Q2. Which of the following tag is used for new paragraph in the documents?
(a) <p>
(b) <br>
(c) <hr>
(d) <break>
Answer: (a) <p>
Exam Concept: <p>...</p> defines a paragraph block with top/bottom spacing.
Paper I · Unit 2 MCQ (1M)
Q3. Which of the following tag is not an empty tag?
(a) <p>
(b) <br>
(c) <hr>
(d) <li>
Answer: (a) <p> (paired/container tag; note <li> also closes with </li>)
Exam Concept: <br> and <hr> are empty (singular) tags, whereas <p>...</p> is a container tag (workbook key specifies (a)).
Paper I · Unit 2 MCQ (1M)
Q4. Which of the following is not web browser?
(a) Netscape Navigator
(b) Internet Explorer
(c) Mozilla Firefox
(d) Notepad
Answer: (d) Notepad
Exam Concept: Notepad is a plain text editor used to write HTML files; the others are web browsers.
Paper I · Unit 2 MCQ (1M)
Q5. Which of the following tags is used for bold facing the text?
(a) <br>
(b) <strong>
(c) <tt>
(d) <li>
Answer: (b) <strong>
Exam Concept: Both <b> and semantic <strong> render text in bold.
Paper I · Unit 2 MCQ (1M)
Q6. Which of the image file extension cannot be inserted in the web page?
(a) .pcd
(b) .gif
(c) .jpg
(d) .jpeg
Answer: (a) .pcd
Exam Concept: Browsers natively support .gif, .jpg/.jpeg, .png, .svg, .webp, NOT Kodak Photo CD .pcd.
Paper I · Unit 2 MCQ (1M)
Q7. You can insert ________ images in your web pages.
(a) 1
(b) 2
(c) 5
(d) No Limit
Answer: (d) No Limit
Exam Concept: HTML places no fixed numeric cap on <img> elements per document.
Paper I · Unit 2 MCQ (1M)
Q8. Which HTML tag would be used to display power in expression X^n + Y = 10?
(a) <sup>
(b) <sub>
(c) <b>
(d) <p>
Answer: (a) <sup>
Exam Concept: X<sup>n</sup> displays superscripts/exponents; <sub> displays subscripts like H<sub>2</sub>O.
Paper I · Unit 2 MCQ (1M) Erratum Fixed
Q9. Choose the correct HTML code to create an email link?
(a) <a href = "xx 2 yy. Com"></a>
(b) <a href="[email protected]"></a> (correctly mailto:[email protected])
(c) <mail>[email protected]</mail>
(d) <a mailhref = [email protected]></a>
Answer: (b) <a href="mailto:[email protected]">...</a>
Exam Concept: The mailto: URI scheme inside <a href="..."> launches the default email client.
Workbook Key Note / Correction: Workbook PDF drops the colon in "[email protected]"; standard valid HTML requires href="mailto:[email protected]".
Paper I · Unit 2 MCQ (1M) Erratum Fixed
Q10. Choose the correct HTML tag for the largest heading?
(a) <h1>
(b) <h2>
(c) <h4>
(d) <h6>
Answer: (a) <h1> [Workbook key prints typo (d) though Page 16 Q47 confirms <h1>]
Exam Concept: HTML headings range from <h1> (largest) down to <h6> (smallest).
Workbook Key Note / Correction: Workbook Answer Key for Unit II-B Q10 misprints (d) (<h6>), contradicting Q47 on the very next page ("What represents the largest heading tag? <h1>"). The true largest heading is (a) <h1>!
Paper I · Unit 2 MCQ (1M)
Q11. Which of the following is not an attribute of <font> tag
(a) color
(b) bgcolor
(c) size
(d) face
Answer: (b) bgcolor
Exam Concept: Legacy <font> supports color, size, and face (bgcolor belongs to <body> or <table>).
Paper I · Unit 2 MCQ (1M)
Q12. <li> is used to create items of an ________
(a) Ordered list
(b) Unordered list
(c) Neither of a and b
(d) Both a and b
Answer: (d) Both a and b
Exam Concept: <li> (List Item) works identically inside both <ol> (Ordered) and <ul> (Unordered) lists.
Paper I · Unit 2 MCQ (1M)
Q13. An ordered list ________
(a) can be nested in an unordered list
(b) can be nested in another ordered list
(c) starts with <list> tag
(d) ends with </li> tag
Answer: (a & b)
Exam Concept: HTML supports nesting <ol> inside both <ul> and <ol>, starting with <ol> and ending with </ol>.
Paper I · Unit 2 MCQ (1M)
Q14. Which of the following control allows the user to select multiple values?
(a) Menu Control
(b) Checkbox Control
(c) Frame
(d) Radio Button
Answer: (b) Checkbox Control
Exam Concept: Checkboxes permit selecting multiple independent choices; Radio buttons allow only one selection per group.
Paper I · Unit 2 MCQ (1M)
Q15. Which of the following is not a form control in HTML? [Workbook key prints (d) Reset Button though standard HTML uses <input type="radio" / "reset">]
(a) Checkbox
(b) Radio Box
(c) Submit Button
(d) Reset Button
Answer: (d) Workbook Key [Note: all 4 input types exist; radio is strictly "Radio Button"]
Exam Concept: Note HTML form <input> supports checkbox, radio, submit, and reset.
Paper I · Unit 2 MCQ (1M)
Q16. Which tag is used to display a picture on a web page?
(a) picture
(b) image
(c) img
(d) src
Answer: (c) img (<img> with src attribute)
Exam Concept: Images are embedded using <img src="pic.jpg" alt="Description">.
Paper I · Unit 2 MCQ (1M)
Q17. Except <b> which other tag is used to make text bold?
(a) <strong>
(b) <dar>
(c) <black>
(d) <bold>
Answer: (a) <strong>
Exam Concept: <strong> emphasizes strong importance and renders in bold.
Paper I · Unit 2 MCQ (1M)
Q18. Which of the following is not a pair tag?
(a) <p>
(b) <u>
(c) <i>
(d) <img>
Answer: (d) <img>
Exam Concept: <img> is a singular/empty tag with no closing </img> tag.
Paper I · Unit 2 MCQ (1M)
Q19. To create HTML document you require a
(a) Web page editing software
(b) High powered computer
(c) Notepad
(d) None of these
Answer: (c) Notepad (or any plain text/code editor)
Exam Concept: Any basic ASCII/UTF-8 text editor like Notepad creates .html pages.
Paper I · Unit 2 MCQ (1M)
Q20. The properties of an HTML element or tag is called
(a) tags
(b) attributes
(c) values
(d) None of these
Answer: (b) attributes
Exam Concept: Attributes sit inside start tags as name="value" pairs controlling tag behavior.
Paper I · Unit 2 MCQ (1M)
Q21. HTML documents are saved in
(a) binary format
(b) machine language
(c) ASCII text
(d) None of these
Answer: (c) ASCII text (plain text with .html/.htm extension)
Exam Concept: HTML files are human-readable plain text documents, not compiled binary executables.
Paper I · Unit 2 MCQ (1M)
Q22. The tags which encloses text inside it are
(a) couple tags
(b) single tags
(c) double tags
(d) paired tags
Answer: (d) paired tags
Exam Concept: Paired (container) tags require both an opening <tag> and a closing </tag>.
Paper I · Unit 2 Fill in Blank / T-F
Q23. In the <hr> tag hr stands for ________.
Answer: Horizontal Rule
Exam Concept: <hr> draws a thematic horizontal divider line across the page.
Paper I · Unit 2 Fill in Blank / T-F Erratum Fixed
Q24. Tags and text that are not directly displayed on the page are written in ________ section.
Answer: <head> section [Workbook prints "Title"]
Exam Concept: Anything placed inside <head> describes the document rather than appearing inside the document canvas.
Workbook Key Note / Correction: Workbook key says "Title", whereas technically the <head>...</head> section holds metadata, <title>, <style>, and <meta> not rendered in the page body.
Paper I · Unit 2 Fill in Blank / T-F
Q25. Which tag is used to insert a horizontal line in a web page?
Answer: <hr>
Exam Concept: <hr> creates a horizontal thematic break.
Paper I · Unit 2 Fill in Blank / T-F
Q26. ________ is the first tag in an HTML document?
Answer: <html> (preceded optionally by <!DOCTYPE html>)
Exam Concept: <html> is the root container element enclosing <head> and <body>.
Paper I · Unit 2 Fill in Blank / T-F
Q27. ________ is used to create ordered and unordered list or bulleted list.
Answer: <li> (inside <ol> or <ul>)
Exam Concept: <ol> defines ordered/numbered lists, <ul> defines unordered/bulleted lists, and <li> defines each list item.
Paper I · Unit 2 Fill in Blank / T-F
Q28. Bulleted list is known by another name which is ________
Answer: Unordered list (<ul>)
Exam Concept: Unordered lists display bullets (disc, circle, or square).
Paper I · Unit 2 Fill in Blank / T-F
Q29. The application software required to view and explore web pages is called ________.
Answer: Web Browser
Exam Concept: Examples: Google Chrome, Mozilla Firefox, Safari, Microsoft Edge.
Paper I · Unit 2 Fill in Blank / T-F
Q30. A simple text editing program (misprinted "word processor") is called ________ Text Editor
Answer: Text editor (e.g., Notepad)
Exam Concept: Notepad writes unformatted ASCII/UTF-8 text cleanly for HTML source code.
Paper I · Unit 2 Fill in Blank / T-F
Q31. Google Chrome is a ________ Web Browser
Answer: Web Browser
Exam Concept: A graphical browser developed by Google.
Paper I · Unit 2 Fill in Blank / T-F
Q32. Notepad is a ________ Text editor
Answer: Text Editor
Exam Concept: Basic built-in Windows plain text editor.
Paper I · Unit 2 Fill in Blank / T-F
Q33. Special formatted text or commands in HTML is called ________.
Answer: Tags / Elements
Exam Concept: Markup instructions enclosed inside < ... > angle brackets.
Paper I · Unit 2 Objective / Short (1–2M)
Q34. What does "vlink" attribute mean?
Answer: Visited Link — sets the color of hyperlinks that the user has already visited (<body vlink="purple">).
Exam Concept: Compare link (unvisited), alink (active while clicked), and vlink (already visited).
Paper I · Unit 2 Objective / Short (1–2M) Erratum Fixed
Q35. What is used to link various web pages?
Answer: Anchor tag <a> with its href attribute (<a href="page2.html">...</a>) [Workbook key writes <href>]
Exam Concept: Hyperlinks connect HTML pages using <a href="URL">Link Text</a>.
Workbook Key Note / Correction: href is an attribute, not a standalone tag! Always write <a href="..."> in exams.
Paper I · Unit 2 Objective / Short (1–2M)
Q36. Which tag contains both opening and closing tag?
Answer: Paired tag (Container tag), e.g. <b>...</b>
Exam Concept: Encloses content between <tag> and </tag>.
Paper I · Unit 2 Objective / Short (1–2M)
Q37. Which tag contains only opening tag?
Answer: Singular tag (Empty / Void tag), e.g. <br>, <hr>, <img>
Exam Concept: Needs no matching closing tag.
Paper I · Unit 2 Objective / Short (1–2M)
Q38. Which tag contains the information about a web page?
Answer: <title> (nested inside <head>)
Exam Concept: Sets the web page title displayed in browser tabs and bookmarks.
Paper I · Unit 2 Objective / Short (1–2M)
Q39. What is the maximum no. of characters supported in HTML title?
Answer: 64 characters (traditional HTML style guideline)
Exam Concept: Browsers technically display longer strings truncated around ~60–64 characters in tabs/SEO.
Paper I · Unit 2 Objective / Short (1–2M)
Q40. Which tag in HTML displays heading?
Answer: <h1> ... <h6>
Exam Concept: Six hierarchical heading levels from <h1> down to <h6>.
Paper I · Unit 2 Objective / Short (1–2M)
Q41. Which tag in HTML is used to create italic font?
Answer: <i> ... </i> (or <em>)
Exam Concept: Renders italicized emphasis text.
Paper I · Unit 2 Objective / Short (1–2M)
Q42. Which tag in HTML is used to create teletype (typewriter) letter font?
Answer: <tt> ... </tt> (monospace teletype)
Exam Concept: Legacy HTML fixed-width monospace font tag (replaced by <code> / CSS in HTML5).
Paper I · Unit 2 Objective / Short (1–2M) Erratum Fixed
Q43. Which tag in HTML is used to represent text with horizontal strikethrough ("stinking" typo) text?
Answer: <strike> ... </strike> (or <del> / <s>)
Exam Concept: Draws a horizontal line across the middle of the text.
Workbook Key Note / Correction: Workbook PDF misprints "stinking text" instead of "strikethrough text".
Paper I · Unit 2 Objective / Short (1–2M)
Q44. Which tag in HTML is used to scroll text on a web page?
Answer: <marquee> ... </marquee>
Exam Concept: Scrolls text or images left, right, up, or down inside the container.
Paper I · Unit 2 Objective / Short (1–2M)
Q45. How many types of heading tags are there?
Answer: 6 heading tags (<h1> through <h6>)
Exam Concept: <h1> has the highest hierarchy/size and <h6> has the lowest.
Paper I · Unit 2 Objective / Short (1–2M)
Q46. What represents the smallest heading tag?
Answer: <h6>
Exam Concept: <h6> renders the smallest default browser heading font size.
Paper I · Unit 2 Objective / Short (1–2M)
Q47. What represents the largest heading tag?
Answer: <h1>
Exam Concept: <h1> renders the largest default browser heading font size.
Paper I · Unit 2 Objective / Short (1–2M)
Q48. Which tag is used to create a line break?
Answer: <br>
Exam Concept: Moves following content onto the next line without starting a new paragraph.
Solved Paper-II Short Objective Questions (17 Qs) Click to Expand
Paper II · Unit 2 Objective / Short (1–2M)
Q1. What is an access specifier?
Answer: Access Specifiers (or Access Modifiers) are reserved keywords in object-oriented languages like Java that define the visibility/accessibility scope of classes, constructors, data variables, and methods from other classes or packages.
Paper II · Unit 2 Objective / Short (1–2M)
Q2. Mention different types of access specifiers.
Answer: Java provides 4 Access Modifiers:
1. public — Accessible everywhere (same class, same package, subclasses, outside packages).
2. protected — Accessible within the same package AND in subclasses outside the package.
3. default (package-private, no keyword) — Accessible only to classes inside the same package.
4. private — Accessible strictly inside the declaring class only.
Paper II · Unit 2 Objective / Short (1–2M)
Q3. Write the use of substring() function with an example.
Answer: Extracts a portion of text from a string starting at a given position.
• MySQL SQL: SELECT SUBSTRING('hello', 2, 3); → Output: llo (1-indexed start=2, length=3).
• Java String: "hello".substring(1, 4); → Output: "ell" (0-indexed start=1 inclusive, end=4 exclusive).
Paper II · Unit 2 Objective / Short (1–2M)
Q4. Distinguish between static and dynamic pages in a website.
Answer: • Static Web Pages: Fixed pre-written HTML content identical for every visitor; requires manual HTML editing; runs on Web Server alone.
• Dynamic Web Pages: Content changes per user, time, or DB state; served by Web Server + Application Server (PHP/Java) + Database (MySQL).
Paper II · Unit 2 Objective / Short (1–2M)
Q5. Distinguish between LCASE() and UCASE().
Answer: • LCASE(str) / LOWER(str): Converts all characters to lowercase. Example: SELECT LCASE('HELLO'); → 'hello'.
• UCASE(str) / UPPER(str): Converts all characters to uppercase. Example: SELECT UCASE('hello'); → 'HELLO'.
Paper II · Unit 2 Objective / Short (1–2M)
Q6. Distinguish between RIGHT() and RTRIM() functions with example.
Answer: • RIGHT(str, n): Extracts the rightmost n characters. Example: SELECT RIGHT('hello', 3); → 'llo'.
• RTRIM(str): Removes trailing spaces from the right side of a string. Example: SELECT RTRIM('hello '); → 'hello'.
Paper II · Unit 2 Objective / Short (1–2M)
Q7. What is HTML?
Answer: HTML stands for HyperText Markup Language — the standard markup language of the World Wide Web used to structure and display formatted text, hyperlinks, images, tables, and forms inside web browsers.
Paper II · Unit 2 Objective / Short (1–2M)
Q8. What are Tags?
Answer: HTML Tags are hidden keywords enclosed inside angle brackets (<tagname>) that instruct the web browser how to structure, format, and display content.
Paper II · Unit 2 Objective / Short (1–2M)
Q9. Do all HTML tags have an end tag?
Answer: No. Empty / Singular tags (such as <br>, <hr>, <img>, <input>) perform standalone layout tasks and do not require an end/closing tag.
Paper II · Unit 2 Objective / Short (1–2M)
Q10. How many types of heading does an HTML contain?
Answer: 6 heading levels: <h1> (largest heading) down through <h2>, <h3>, <h4>, <h5>, to <h6> (smallest heading).
Paper II · Unit 2 Objective / Short (1–2M)
Q11. How to create a hyperlink in HTML?
Answer: Using the Anchor tag <a> with the href attribute: <a href="https://nextnote.in">Visit NextNote</a>.
Default link states: Unvisited = blue & underlined; Visited = purple; Active = red.
Paper II · Unit 2 Objective / Short (1–2M)
Q12. Which HTML tag is used to display the data in the tabular form?
Answer: <table>...</table> along with <tr> (table row), <th> (header cell), and <td> (table data cell).
Paper II · Unit 2 Objective / Short (1–2M)
Q13. What are some common lists that are used when designing a page?
Answer: 1. Ordered List (<ol>): Numbered sequence (1, 2, 3 or A, B, C / I, II).
2. Unordered List (<ul>): Bulleted list (disc, circle, square), using <li> for items.
3. Description List (<dl>, <dt>, <dd>).
Paper II · Unit 2 Objective / Short (1–2M)
Q14. What is the difference between HTML elements and tags?
Answer: An HTML **Tag** is strictly the markup delimiter (<p> or </p>), whereas an HTML **Element** includes the opening tag + inner content + closing tag (<p>Hello</p>).
Paper II · Unit 2 Objective / Short (1–2M)
Q15. Does a hyperlink only apply to text?
Answer: No. You can wrap an <a href="..."> tag around BOTH text and images (<a href="page.html"><img src="btn.png"></a>).
Paper II · Unit 2 Objective / Short (1–2M)
Q16. What is a marquee?
Answer: <marquee>Scrolling Text</marquee> is an HTML container tag used to automatically scroll text or images horizontally/vertically across a web page.
Paper II · Unit 2 Objective / Short (1–2M)
Q17. How to make a picture a background image of a web page?
Answer: Add the background attribute inside the <body> opening tag right after </head>: <body background="image.gif"> (or modern CSS background-image: url('image.gif');).