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.