Page 119 - CITS - CSA - TP (Volume 2) - Hindi
P. 119
कं ूटर सॉ वेयर ए ीके शन - CITS
अ ास 96: िविधयों से डेटा और ऑ े रटन (Return data and Objects from Methods)
उ े
इस अ ास के अंत म आप यह कर सक गे
• JAVA म िविधयों से डेटा और ऑ े रटन करने के तरीके के बारे म जान
• िविधयों से डेटा और ऑ े वापस करने के िलए जावा ो ाम डेवलप कर ।
आव कताएं (Requirements)
उपकरण/साम ी (Tools/Materials)
• िवंडोज OS वाला PC/लैपटॉप
• JDK सॉ वेयर
• टे एिडटर (िवजुअल ू िडयो/स ाइम/नोटपैड)
ि या (Procedure)
नीचे जावा ो ामों के उदाहरण िदए गए ह जो िविधयों से डेटा और ऑ े लौटाते ह :
टा 1: दो सं ाओं म से अिधकतम सं ा लौटाना
public class MaxNumberDemo {
public static void main(String[] args) {
int a = 10;
int b = 20;
// Calling the method to find the maximum of two numbers
int max = findMax(a, b);
System.out.println(“Maximum of “ + a + “ and “ + b + “ is: “ + max);
}
// Method to find the maximum of two numbers
public static int findMax(int x, int y) {
return (x > y) ? x : y;
}
}
आउटपुट:
105

