1.WAJP
to create and demonstrate packages.
Program:
Package:
package com.edu.cllege;
public class parent
{
public void m1()
{
System.out.println("parent m1()");
}
}
public class parent
{
public void m1()
{
System.out.println("parent m1()");
}
}
Program:
package org.edu1.college1;
import java.io.*;
import com.edu.college.parent;
class Child extends com.edu.college.Parent
{
void m2()
{
System.out.println("calling superclass method");
m1();
}
}
class PackageTest
{
public static void main(String[] args) throws Exception
{
File F=new File("My file.txt");
parent obj=new Parent();
child obj1=new Child();
obj.m1();
obj.m2();
}
if(!f.exists())
{
F.createNewFile();
System.out.println("file create");
}
else
{
System.out.println("error in file creation");
}
}
}
import java.io.*;
import com.edu.college.parent;
class Child extends com.edu.college.Parent
{
void m2()
{
System.out.println("calling superclass method");
m1();
}
}
class PackageTest
{
public static void main(String[] args) throws Exception
{
File F=new File("My file.txt");
parent obj=new Parent();
child obj1=new Child();
obj.m1();
obj.m2();
}
if(!f.exists())
{
F.createNewFile();
System.out.println("file create");
}
else
{
System.out.println("error in file creation");
}
}
}
0 comments:
Post a Comment