What is class in java give real time example? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 3

What is class in java give real time example?

meaning

5th Jul 2018, 1:47 AM
Nithish Krish
Nithish Krish - avatar
1 Answer
+ 1
A class in Java is like a recipe for baking cookies. It defines what ingredients (attributes) are needed, along with the steps (methods) to follow. Just as the recipe can be used to create multiple batches of cookies, a class can be used to create multiple objects with shared characteristics and behaviors. Real-time example⤵️ Let's consider a class named "Car" in Java. This class could have attributes like "brand", "model", "color", etc., and methods like "start()", "stop()", "accelerate()", etc. Objects created from this class would represent individual cars with their specific attributes and behaviors.
12th Apr 2024, 8:02 PM
`нттp⁴⁰⁶
`нттp⁴⁰⁶ - avatar