Skip to content
← Information Technology

Information Technology · Class 12 Commerce

Ch 2Programming — Class 12 Information Technology, concept-first.

In the first year you learned to write simple Java programs — declaring variables, using operators, taking decisions with if/switch, repeating work with loops, and organising code into methods. This chapter builds directly on that foundation, so we begin with a short review to fix the vocabulary we will keep using.

14

Q&A

6

Concepts

Not available

Exam weightage

Start learning — read this chapter →

Key concepts

Hover a concept to preview it and jump to its most relevant Q&A.

Access Specifiers and Encapsulation

Access specifiers control who may use a class member: public (anywhere), private (same class only), protected (class, package and subclasses) and default (same package).

Start with this concept →

Chapter contents

The NCERT structure, section by section. Open a section to see its questions, then read the concept-first solution.

1

Programming Fundamentals — A Quick Review

In the first year you learned to write simple Java programs — declaring variables, using operators, taking decisions with if/switch, repeating work with loops, and organising code into methods.

2

Access Specifiers and Encapsulation

When a class has fields and methods, we usually do not want every other part of the program to reach in and change them freely.

3

Inheritance

Inheritance lets one class reuse the fields and methods of another class instead of rewriting them. The class we inherit from is the parent (also called superclass or base class); the class that inher…

4

Common Library Classes — String and Math

Java ships with a large collection of ready-made classes called the standard library. Instead of writing common operations yourself, you call methods that are already written and tested.

5

Connecting Java to a MySQL Database — ODBC and JDBC

Most real programs must store and fetch data from a database. In this course the database is MySQL (a relational database that keeps data in tables).

6

Building a Web Page with HTML — Basic Tags

A web page is a document you view in a browser. Web pages are written in HTML — HyperText Markup Language.

7

HTML Tables, Lists and Forms

Beyond plain text, HTML gives us structured elements to organise information: tables for rows and columns, lists for items, and forms to collect input from the visitor.

8

Static vs Dynamic Pages, DHTML and an Introduction to XML

Not all web pages behave the same way. A key distinction is between static and dynamic pages, and alongside plain HTML you will meet two related terms — DHTML and XML.

Exercises

+Show 14 questions14 questions
  1. Q1What are access specifiers in Java? Name the four levels and state, for each, from where a member can be accessed.Free
  2. Q2What is encapsulation? Explain how making a field `private` with public getter and setter methods protects an object's data, with a short ex…Free
  3. Q3Define inheritance. Write a Java program in which a class `Student` inherits from a class `Person`, reusing a field and a method of `Person`…Free
  4. Q4What is method overriding? Explain the role of the `super` keyword, giving a short example.Preview
  5. Q5Which types of inheritance does Java support for classes, and which does it not? Explain why the unsupported one is disallowed.Preview
  6. Q6Predict the output of the following code and explain each result: ```java String s = "Commerce"; System.out.println(s.length()); System.out.…Preview
  7. Q7Why should `equals()` be used instead of `==` to compare two strings? Illustrate with a short example.Preview
  8. Q8Using the `Math` class, write Java statements to compute (i) the square root of 225, (ii) 2 raised to the power 10, and (iii) the larger of…Preview
  9. Q9Distinguish between ODBC and JDBC. Why is JDBC generally preferred for a Java program?Preview
  10. Q10List, in order, the five steps a Java program follows to connect to and read from a MySQL database using JDBC, naming the key object involve…Preview
  11. Q11Write the HTML code for a complete web page whose browser-tab title is "My Page" and which displays a main heading "Welcome" and a paragraph…Preview
  12. Q12Write HTML to display a table with the heading row "Roll" and "Name" and one data row "1" and "Rina". Also state which tags create (i) a row…Preview
  13. Q13Differentiate between a static web page and a dynamic web page, with one example of each.Preview
  14. Q14What is XML, and how does it differ from HTML? Give a small XML example that stores one student's roll, name and marks.Preview