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 is a contributor for websites such as Webopedia.com and Enterprise Storage Forum. She writes about information technology security, networking, and data storage. Jenna lives in Nashville, TN.

Top Articles

The Complete List of 1500+ Common Text Abbreviations & Acronyms

From A3 to ZZZ we list 1,559 SMS, online chat, and text abbreviations to help you translate and understand today's texting lingo. Includes Top...

Windows Operating System History & Versions

The Windows operating system (Windows OS) refers to a family of operating systems developed by Microsoft Corporation. We look at the history of Windows...

How to Create a Website Shortcut on Your Desktop

Website Shortcut on Your Desktop reviewed by Web Webster   This Webopedia guide will show you how to create a website shortcut on your desktop using...

Generations of Computers (1st to 5th)

Reviewed by Web Webster Learn about each of the 5 generations of computers and major technology developments that have led to the computing devices that...

Pardot

What is Pardot? Pardot is a B2B marketing automation (MA) solution by Salesforce that...

Veeam

Veeam Software is a global vendor...

Akamai

Akamai Technologies is a global web technology company specializing in content...