Lesson 25 of 34

Classes, Objects

10 min 30 XP

Java object-oriented ആണ്. Class എന്നത് fields (data), methods (പ്രവൃത്തികൾ) എന്നിവയുള്ള ഒരു രൂപരേഖയാണ് (blueprint). അതിൽ നിന്ന് new ഉപയോഗിച്ച് objects ഉണ്ടാക്കുന്നു, ഓരോ object-നും സ്വന്തം values ഉണ്ട്.

Example: edit me and press Run

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.

ഒരു file-ൽ ഒരു public class മാത്രമേ പാടുള്ളൂ. മറ്റ് classes Main-ന് മുകളിൽ public എന്ന വാക്കില്ലാതെ എഴുതൂ.

Challenge

+30 XP

length, width fields-ഉം area(), perimeter() methods-ഉം ഉള്ള class Rectangle എഴുതൂ. main()-ൽ length, width വായിച്ച് print ചെയ്യൂ: Input: 5 3 Output: Area: 15 Perimeter: 16

Output Loading Java (first time takes a few seconds)
Press Run to see the result here.