what is a class?
what is a class?
Page 1 of 13 Replies - 249 Views - Last Post: 10 April 2012 - 10:30 AM
Replies To: what is a class?
#2
Re: what is a class?
Posted 10 April 2012 - 03:53 AM
Classes are the fundamental building blocks of a Java program. You can define an Employee class as follows:
By convention, class names capitalize the initial of each word.
For example: Employee, Boss, DateUtility, PostOffice, RegularRateCalculator.
This type of naming convention is known as Pascal naming convention.
The other convention, the camel naming convention, capitalize the initial of each word, except the first word.
Method and field names use the camel naming convention.
You can read more about it HERE
Or go HERE to see some resource threads by some of "us" here in DIC
class Employee {
int age;
double salary;
}
By convention, class names capitalize the initial of each word.
For example: Employee, Boss, DateUtility, PostOffice, RegularRateCalculator.
This type of naming convention is known as Pascal naming convention.
The other convention, the camel naming convention, capitalize the initial of each word, except the first word.
Method and field names use the camel naming convention.
You can read more about it HERE
Or go HERE to see some resource threads by some of "us" here in DIC
#3
Re: what is a class?
Posted 10 April 2012 - 10:03 AM
One way to visualize a class is to see it as an abstraction of a real life object. Classes in Java can store data, but can also describe the behaviour of the object itself.
Take a car for example (the ones who're already familiar with my explanation, yes I am always using a car), a car has certain properties, like the amount of fuel it can store, the color, amount of passengers, etc. But a car can also drive, brake and idle.
In short:
- In Java the car would be an object
- The properties of the car would be the properties of the object
- The behaviour of the car would be described by the methods of the objects
By conventions:
- Class names are Pascal typed (see post above) and are always nouns
- Methods of the class are camelcased and start with a verb. E.g. getCarColor() (which would retrieve the color of the car)
- Constants are CAPITALIZED
- Variables are camelcased
Obviously, the names should have a meaningful name.
Finally, there are also concepts related with classes such as
- inheritance and
- abstract classes and interfaces
As you can see, a class may look small, but it's use is what makes it powerful in Java.
Take a car for example (the ones who're already familiar with my explanation, yes I am always using a car), a car has certain properties, like the amount of fuel it can store, the color, amount of passengers, etc. But a car can also drive, brake and idle.
In short:
- In Java the car would be an object
- The properties of the car would be the properties of the object
- The behaviour of the car would be described by the methods of the objects
By conventions:
- Class names are Pascal typed (see post above) and are always nouns
- Methods of the class are camelcased and start with a verb. E.g. getCarColor() (which would retrieve the color of the car)
- Constants are CAPITALIZED
- Variables are camelcased
Obviously, the names should have a meaningful name.
Finally, there are also concepts related with classes such as
- inheritance and
- abstract classes and interfaces
As you can see, a class may look small, but it's use is what makes it powerful in Java.
This post has been edited by karabasf: 10 April 2012 - 10:04 AM
#4
Re: what is a class?
Posted 10 April 2012 - 10:30 AM
A class, I'm guessing, is where you got this question on your homework assignment.
Page 1 of 1
|
|

New Topic/Question
Reply



MultiQuote





|