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... Continue Reading →

Advertisements

31. An example of user define package –

package Package1; public class ClassA {                 public void displayA()                 {                                 System.out.println("Class A");                 } } Name of the source file must be saved as ClassA.java and stored it in the subdirectory Package1. Now compile this java file with ClassA.class and it must be stored in the same directory. Now design a main... Continue Reading →

Create a website or blog at WordPress.com

Up ↑

%d bloggers like this: