LEC : 19 || JAVA
LEC:19
package oops;
import java.util.Scanner;
class Student{
private
int i;
// void display()
// {
// System.out.println("Hello new Class and their Objects...");
// }
// int get()
// { int a=99;
// return a;
// }
//Constructor
Student()
{
i=99;
System.out.println("Default Constructor is Calling "+i);
}
Student(int a)
{
i=a;
System.out.println("Parameterized Constructor is Calling "+i);
}
}
public class OOPS {
public static void main(String[] args) {
//Object creation and calling method also passing the values
Student O1=new Student();
Scanner O4=new Scanner(System.in);
int input=O4.nextInt();
Student O2=new Student(input);
// O1.display();
// int hold=O1.get();
// System.out.println("The value of a is : "+hold);
}
}
Comments
Post a Comment