Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

6.

To demonstrate packages

package javapack;

public class New

public void show()

System.out.println("Java is an object-oriented language");

package javapack;

public class New1

public void display()

System.out.println("C is a Procedural Oriented language");

import javapack.New;

import javapack.New1;

class PackageEx{

public static void main(String args[]){

New obj1 = new New();

obj1.show();

New1 obj2 = new New1();

obj2.display();

}
7. /*To demonstrate string class Methods*/

class StringEx{

public static void main(String args[]){

String str = new String("Neeraj");

System.out.println(str);

System.out.println(str.length());

System.out.println(str.indexOf("e"));

System.out.println(str.charAt(4));

System.out.println(str.toUpperCase());

System.out.println(str.toLowerCase());

System.out.println(str.compareTo("neeraj"));

System.out.println(str.trim());

You might also like