Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors

Differentiate between a class and object with some example. Also prepare a list of objects that you would expect each of the following systems to handle : (1) a program for laying out a news paper, (2) a catalog store order entry system.

S. No.AspectClassObject
1.DefinitionBlueprint or template from which objects are createdInstance of a class
2.GroupingRepresents a group of similar objectsA real-world entity with specific attributes
3.NatureLogical entityPhysical entity
4.DeclarationDeclared using the class keywordCreated through the new keyword
5.InstancesDeclared onceCreated many times as per requirement
6.Memory AllocationDoes not allocate memory when createdAllocates memory when created

Examples:

  1. Program for laying out a newspaper:
    • Classes: Page, Column, Line, Headline, Paragraph
    • Objects:
      • Page1, Page2, Page3 (instances of the Page class)
      • Column1, Column2 (instances of the Column class)
      • Headline1, Headline2 (instances of the Headline class)
  2. Catalog store order entry system:
    • Classes: Customer, Order, Store, Item
    • Objects:
      • Customer1, Customer2 (instances of the Customer class)
      • Order1, Order2 (instances of the Order class)
      • Store1, Store2 (instances of the Store class)
      • Item1, Item2 (instances of the Item class)

In the newspaper layout program, each class represents a distinct component of the layout, and objects are instances of these classes representing specific elements on a page.

In the catalog store order entry system, the classes represent entities involved in the ordering process, and objects are instances representing specific customers, orders, stores, and items in the system.

Leave a Comment