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.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.
Get the Free Newsletter
Subscribe to Daily Tech Insider for top news, trends & analysis
This email address is invalid.

Related Articles

Embedded Analytics

Embedded analytics brings self-service business intelligence to everyday application users.

HRIS

Human resources information system (HRIS) solutions help businesses manage multiple facets of their workforce operations. They provide a central platform for human resources professionals...

Complete List of Cybersecurity Acronyms

Cybersecurity news and best practices are full of acronyms and abbreviations. Without understanding what each one means, it's difficult to comprehend the significance of...

Human Resources Management System

A Human Resources Management System (HRMS) is a software application that supports many functions of a company's Human Resources department, including benefits administration, payroll,...

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...