Monday, 5 October 2015

First java OOPS program (Object creation for a class)

/**
 *
 */

/**
 * @author U0123154
 *
 */
public class ObjectsandClasses {

/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
First a = new First();
a.deom(10);
}
}


Class:-
//import java.lang.*;
public class First {
private int i;
int k;
void deom(int i)
{
this.i=i;
System.out.println("Variable is initilized and it's value is " +i);
}
}



Output:-
Variable is initilized and it's value is 10

No comments:

Post a Comment