Page 104 - CITS - CSA - TP (Volume 2) - Hindi
P. 104
कं ूटर सॉ वेयर ए ीके शन - CITS
आउटपुट :
ीकरण:
• यह ो ाम मेक, मॉडल और वष जैसे गुणों के साथ एक कार ास को प रभािषत करता है।
• इसम इं स वै रएबल को इिनिशयलाइज़ करने के िलए एक कं र है।
• displayInfo() िविध कार की जानकारी ि ंट करती है।
• main() िविध म , Car ास का एक ऑ े myCar बनाया जाता है, और इसके गुणों को displayInfo() िविध का उपयोग करके ए ेस िकया
जाता है।
टा 5: सक ल ास
class Circle {
// Instance variable
double radius;
// Constructor
Circle(double r) {
radius = r;
}
// Method to calculate area
double calculateArea() {
return Math.PI * radius * radius;
}
// Method to calculate circumference
double calculateCircumference() {
return 2 * Math.PI * radius;
}
}
public class CircleDemo {
public static void main(String[] args) {
// Create an object of Circle class
90
CITS : IT & ITES - कं ूटर सॉ वेयर ए ीके शन - अ ास 94

