Example 1 : Java OOP

We used two java files,

smo_main.java

public class smo_main {
public static void main(String[] args) {
int x=5;
int y=16;
smo_1 obj1=new smo_1();
System.out.println(obj1.my_add(x,y));
}
}

smo_1.java

public class smo_1 {
int my_add(int x,int y)
{
	return x+y;
}
}
Output
21
Class object method

Subscribe

* indicates required
Subscribe to plus2net

    plus2net.com



    Post your comments , suggestion , error , requirements etc here




    We use cookies to improve your browsing experience. . Learn more
    HTML MySQL PHP JavaScript ASP Photoshop Articles FORUM . Contact us
    ©2000-2024 plus2net.com All rights reserved worldwide Privacy Policy Disclaimer