Skip to content
Computer ApplicationsICSE Class 9 · Elementary Concept of Objects and Classes

Class as a Blueprint, Object Factory and User-Defined Data Type in Java (ICSE Class 9)

Updated 18 October 2026 · Fact-checked

A class is a blueprint that lists the data members (attributes) and member methods (behaviour) common to a group of similar objects. It is an object factory because any number of objects can be made from it with new, each with its own values. It is a user-defined data type because, once written, its name is used to declare variables like int or double.

One class is written once; each new Bulb() makes an object with the same members but its own values, such as watt.

Illustration drawn for QuestionBuddy.

Understand Class as a Blueprint, an Object Factory and a User-Defined Data Type

A class as a specification. A class describes what all objects of one kind will have: data members (variables for the state) and member methods (for the behaviour). Writing a class does not make an object and uses no memory for object data.

class Bulb
{
boolean isOn;
int watt;
void switchOn() { isOn = true; }
void switchOff() { isOn = false; }
}

A class as a blueprint. The architect's plan is the class; each house built from it is an object. Every house has the same design but its own owner and colour: every object has the same data members but its own values.

A class as an object factory. One class produces any number of similar objects on demand. The statement
Bulb b = new Bulb();
does three things: Bulb b declares a reference variable b of the class type; new Bulb() creates the object in memory and gives its reference; = stores the reference in b. Members are reached with the dot operator: b.watt = 60; b.switchOn();

Default values of data members when no value is assigned: int 0, double 0.0, boolean false, char the null character, and reference types such as String null.

A class as a user-defined data type. int, double and char are built into Java. A class lets the programmer create a new type that combines several data members with the methods that work on them. After the class Bulb is written, Bulb can be used to declare variables just as int is. A primitive variable holds one value; a variable of a class type holds a reference to an object, which can hold many values. String and Scanner are also classes, written by Java's designers.

Class and object compared.

  • A class is a template (logical); an object is an instance with real values in memory.
  • One class, many objects.
  • Class names conventionally begin with a capital letter, objects with a small letter.

Neighbouring topics: how objects behave, hold references and exchange messages is on the next page of this chapter.

Class as a Blueprint, an Object Factory and a User-Defined Data Type: key facts

Three views of a class
  • Blueprint (specification)
  • Object factory (many objects with new)
  • User-defined data type
All three are in the syllabus.
Creating an object
  • ClassName obj = new ClassName();
  • obj.member reaches data
  • obj.method() calls behaviour
new allocates memory.
Default values
  • int 0
  • double 0.0
  • boolean false
  • String null
For data members only.

Class as a Blueprint, an Object Factory and a User-Defined Data Type in real life

The idea, met in an everyday situation. Answer the question in your own words, then compare with the model answer. The one-line hook is what to remember.

Class as a blueprint

Suppose a bakery owns one cake mould and bakes cakes from it for different customers, writing a different name on each.

Match the mould, the cakes and the names with classes, objects and attributes.

Try it first, then show the solutionSolution
  1. The mould fixes the shape: the class.
  2. Each cake is an object made from it.
  3. The written name is a value of an attribute, different for every object.

Answer: Mould = class, cake = object, name on the cake = value of an attribute.

Memory hook: One mould, many cakes.

User-defined type

Imagine a school form that needs a Student: name, roll number and marks together, instead of three separate loose items.

Why is a class a good model for the Student?

Try it first, then show the solutionSolution
  1. One class groups the related data members.
  2. A variable of type Student holds all of them together.
  3. Methods such as showResult() can sit beside the data.

Answer: A class creates a new data type, Student, that combines related data and the methods that use it.

Memory hook: Group the data, then name the type.

Tricks to remember Class as a Blueprint, an Object Factory and a User-Defined Data Type

Short memory aids. Say each one aloud once, then use it on a question the same day.

  • BFT

    A class is a Blueprint, a Factory and a Type.

    Use it when: The three views of a class.

  • Declaration is not creation

    A declaration makes a name; new makes the object.

    Use it when: Bulb b; versus Bulb b = new Bulb();

  • Nouns and verbs

    Nouns become data members; verbs become methods.

    Use it when: Designing a class.

Class as a Blueprint, an Object Factory and a User-Defined Data Type: solved examples

Ordered from board level to HOTS. Try each one before you open the solution.

Example 1: Creating an object · 1 mark · MCQBoard level

Which statement creates an object of the class Bulb?
(a) Bulb b; (b) Bulb b = new Bulb(); (c) new b = Bulb(); (d) b = Bulb;

Try it first, then show the solutionSolution
  1. (a) only declares a reference; (c) and (d) are not valid Java.
  2. (b) declares b and creates the object with new.

Answer: (b) Bulb b = new Bulb();

Example 2: Design a class · 4 marks · Short answerHarder board level

Write a class Book with data members title (String), price (double) and pages (int), and a method show() that prints the title and price on one line separated by a space. In main(), create one object, set title to "Atlas" and price to 250.5, and call show(). State the output.

Try it first, then show the solutionSolution
  1. Class with the three data members. (1 mark)
  2. show() prints title + " " + price. (1 mark)
  3. main() creates b = new Book(), sets b.title = "Atlas" and b.price = 250.5 and calls b.show(). (1 mark)
  4. Output: Atlas 250.5 (pages stays 0 and is not printed). (1 mark)

Answer: class Book
{
String title;
double price;
int pages;
void show()
{
System.out.println(title + " " + price);
}
public static void main(String args[])
{
Book b = new Book();
b.title = "Atlas";
b.price = 250.5;
b.show();
}
}
Output: Atlas 250.5

Example 3: Default values · 2 marks · Short answerHarder board level

Give the output (the class Item has data members int qty; double rate; boolean sold; String name; no value is assigned):

Item t = new Item();
System.out.println(t.qty + " " + t.rate + " " + t.sold + " " + t.name);
Try it first, then show the solutionSolution
  1. Numeric data members start at 0 and 0.0.
  2. boolean starts false and a String reference starts null, which prints as null.

Answer: 0 0.0 false null

Example 4: Case study: the toy factory · 4 marks · Case-basedHOTS / competency

A toy factory writes one class Toy (name, colour, price) and makes 500 toys from it with different values. Programmers call the class "a user-defined data type".
(i) Which view of the class is shown by making 500 toys? (1)
(ii) Give one reason for calling Toy a user-defined data type. (1)
(iii) Write the statement to make a toy t from the class. (1)
(iv) Is Toy a class or an object? Is the toy named t a class or an object? (1)

Try it first, then show the solutionSolution
  1. (i) The class as an object factory (and blueprint).
  2. (ii) It is designed by the programmer and its name can be used to declare variables like a built-in type.
  3. (iii) Toy t = new Toy();
  4. (iv) Toy is a class; t refers to an object (an instance of Toy).

Answer: (i) object factory (ii) created by the programmer and used like a type (iii) Toy t = new Toy(); (iv) Toy is a class, t refers to an object.

Example 5: Counting classes and objects · 3 marks · Short answerHarder board level

A programmer writes the class Car and then creates three cars c1, c2 and c3 with new. (i) How many classes and how many objects are there? (ii) Do c1 and c2 share the same values of the data members? (iii) Was memory used for the cars' data when only the class had been written?

Try it first, then show the solutionSolution
  1. (i) One class and three objects. (1 mark)
  2. (ii) No. Each object has its own copy of the data members with its own values. (1 mark)
  3. (iii) No. A class is only a description; memory for the data is allocated when an object is made with new. (1 mark)

Answer: (i) 1 class, 3 objects (ii) no, each has its own values (iii) no

Where students lose marks in Class as a Blueprint, an Object Factory and a User-Defined Data Type

The slips examiners see most often, and what to write instead.

  • Mistake: Declaring without new

    A declaration is mistaken for an object.

    Wrong working

    Bulb b; b.switchOn();

    Right working

    Bulb b = new Bulb(); b.switchOn();

    Do this: A declaration makes only a name; new makes the object.

    Usually costs: 1 to 2 marks

  • Mistake: Mixing class and object

    Both words are used loosely.

    Wrong working

    A class occupies memory with its own values.

    Right working

    An object occupies memory with its own values; the class is the blueprint.

    Do this: Class = plan, object = instance.

    Usually costs: 1 mark

  • Mistake: Leaving out the type of a data member

    Syntax is rushed.

    Wrong working

    length, breadth;

    Right working

    int length, breadth;

    Do this: Every data member has a type.

    Usually costs: 1 mark

Exam tips

  • Give the three views of a class: blueprint, object factory, user-defined data type.
  • Always follow a definition with an example class such as Bulb or Book.
  • In programs write the class, data members, methods, main(), new and the dot calls in that order.
  • Mention default values when a data member is printed before assignment.

Practice questions on Class as a Blueprint, an Object Factory and a User-Defined Data Type

Write each answer on paper first. Open the hint only if you are stuck, and the answer only when you have finished.

  1. Q1 · 1 mark · MCQBoard level

    A class is also called:
    (a) a variable (b) a user-defined data type (c) a method (d) a keyword

    Hint

    Think of int, double and Bulb.

    Answer

    (b) a user-defined data type

  2. Q2 · 2 marks · Very short answerBoard level

    Explain the statement Bulb b = new Bulb();

    Hint

    Three parts: declare, create, store.

    Answer

    Bulb b declares a reference variable b of class type Bulb. new Bulb() creates a Bulb object in memory and returns its reference, which = stores in b.

  3. Q3 · 4 marks · Short answerHarder board level

    Write a class Rectangle with data members length and breadth (both int) and a method area() that returns length * breadth. Write the statements to create an object r, set length = 12 and breadth = 5, and print the area. State the output.

    Hint

    The method has return type int.

    Answer

    class Rectangle
    {
    int length, breadth;
    int area()
    {
    return length * breadth;
    }
    public static void main(String args[])
    {
    Rectangle r = new Rectangle();
    r.length = 12;
    r.breadth = 5;
    System.out.println(r.area());
    }
    }
    Output: 60

  4. Q4 · 2 marks · Very short answerHarder board level

    Which of these are classes and which are objects: Vehicle, Your school bus, Fruit, The mango on your table?

    Hint

    General versus particular.

    Answer

    Classes: Vehicle and Fruit. Objects: your school bus and the mango on your table.

  5. Q5 · 3 marks · Short answerHOTS / competency

    A student writes Student s; s.marks = 90; and the program stops with an error. Explain the mistake and correct it.

    Hint

    What does a declaration create?

    Answer

    Student s; only declares a reference variable; no object exists yet, so s.marks fails (the compiler reports the variable might not have been initialised). Correct: Student s = new Student(); s.marks = 90;

Test your recall

Answer in your head or on paper first, then open the card. Pulling an answer out of memory makes it stick far better than re-reading.

  1. 1.What does new return?Show answer

    A reference to the new object.

  2. 2.Default value of an int data member?Show answer

    0

  3. 3.Default value of a String data member?Show answer

    null

  4. 4.Is a class a physical or logical entity?Show answer

    Logical.

  5. 5.Operator used to reach an object's members?Show answer

    The dot (.) operator

  6. 6.Name two classes supplied by Java.Show answer

    String and Scanner.

Class as a Blueprint, an Object Factory and a User-Defined Data Type: frequently asked questions

Can many objects be made from one class?

Yes, any number, each with its own values.

Is String a class?

Yes. A String variable refers to an object, unlike int or double, which are primitive.

Are access specifiers needed in Class IX?

The focus is on data members, methods, objects and calls; access specifiers are studied in Class X.