Masters of Computer Science
Class and Objects in Java

Class
- user-defined blueprint in OOP
- a common set of properties are represented by class
- To create a class, you need to use the keyword class
Example:
Class named “Test” is created below
public class Test {
int x=17;
}
- Class describes state and behavior
Remember, class is blueprint form where individual objects are generated
Example
public classCat {
String breed;
int age;
String color;
void mew() {
}
void sleep() {
}
void run() {
}
Object
- the basic unit of OOP
- real-life entities are represented by the object
- In java, an object is created from a class
- Objects have state and behaviour. For example, a cat has a state and behaviour
- States like: Color, name, breed of the cat
- Behaviour like: mewing, moving tail etc
Facebook Comments
-
Software7 days ago
How to clear your all browsers cache?
-
Masters of Computer Science6 days ago
Commands for Files and Directory Handling in Linux
-
Masters of Computer Science6 days ago
History of Open Source Initiative (OSI)
-
Masters of Computer Science5 days ago
Linux Standard Directories
-
Masters of Computer Science6 days ago
Features and Advantages of Linux
-
Masters of Computer Science5 days ago
Overview of Linux Architecture
-
Software4 days ago
Everything You Must Know About Metasploit
-
Masters of Computer Science6 days ago
Open Source Softwares and Principle of Open Source