32. Write a program in java to enter your name in first package and address in second package. And call both packages using main method program to display your name and address?

package Package1;
public class Student
{
                public void name()
                {
                                System.out.println("Vikrant Kumar");
                }
}

 

package Package2;
public class Students
{
                public void address()
                {
                                System.out.println("Bihar");
                }
}

 

import Package1.Student;
import Package2.Students;
class TestPackage
{
                public static void main(String args[])
                {
                                Student object=new Student();
                                Students objects=new Students();
                                object.name();
                                objects.address();
                }
}

JAVA 32.PNG

Advertisements

Comments are closed.

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: