Class Keyword

A class keyword in programming is an indicator that declares a certain class. In object-oriented programming, a class contains and designs objects, holding an object’s informational data and its behavioral patterns (what it can do). These behaviors are also known as methods: processes that are related to the object in question. For example, if a programmer wanted to create a class for the object refrigerator, the class could contain information about the refrigerator:

  • its stainless steel exterior
  • the three shelves
  • a produce drawer

as well as related methods and behaviors:

  • cooling the food by maintaining a specific temperature
  • opening the refrigerator and placing food inside
  • using the ice dispenser to get a drink

The class keyword (simply the word class before anything else) initiates a class declaration and is required before any class. The title of the class follows the keyword:

class Refrigerator { }

All other data and methods (or functions) of the class refrigerator fall between the brackets.

The class keyword and the following class title are the only prefixes required for a class. However, there are optional features that programmers can use to define a class. Programmers can create a class that is public or private and can also denote a superclass of which the current class is a part.






Jenna Phipps
Jenna Phipps
Jenna Phipps is a writer for Webopedia.com, Enterprise Storage Forum, and CIO Insight. She covers data storage systems and data management, information technology security, and enterprise software solutions.

Related Articles

@ Sign

Pronounced at sign or simply as at, this symbol is used in e-mail addressing to separate the user' name from the user's domain name,...

Munging

(MUHN-jing) Munging (address munging), is the act of altering an email address posted on a Web page to make it unreadable to bots and...

How to Create an RSS Feed

In the second installment of RSS how-to, we look at some of the nonrequired (optional) channel and item tags, discuss RSS specifications in-depth and...

Dictionary Attack

(n.) (1) A method used to break security systems, specifically password-based security systems, in which the attacker systematically tests all possible passwords beginning with...

ScalaHosting

ScalaHosting is a leading managed hosting provider that offers secure, scalable, and affordable...

HRIS

Human resources information system (HRIS) solutions help businesses manage multiple facets of their...

Best Managed Service Providers...

In today's business world, managed services are more critical than ever. They can...