Professional Documents
Culture Documents
class Food {
Food() {
System.out.println("Food");
fruit() {
super();
System.out.println("Fruit");
apple() {
super();
System.out.println("apple");
}
PROGRAM NO#2
Shape[] objj= new Shape[6];
objj[0]=new Circle();
objj[1]=new Square();
objj[2]=new Triangle();
objj[3]=new Sphere();
objj[4]=new Cube();
objj[5]=new TetraHedron();
obj[i].getArea(5);
obj[i].getArea(5);
obj[i].getVolume(5);
class Shape{
System.out.println("Area");}
System.out.println("Volume");}
@Override
void getArea(double x){
System.out.println("TwoD.Area");}}
@Override
@Override
@Override
@Override
@Override
}
class TetraHedron extends ThreeDimensionShape{@Override
@Override
PROGRAM NO# 3
public static void main(String[] args) {
getOccuringChar(str);
class NoOfOccurenceOfCharacters {
count[str.charAt(i)]++;
int find = 0;
if (str.charAt(i) == ch[j])
find++;
if (find == 1)
PROGRAM NO# 4
public static void main(String[] args) {
int mat[][] = { { 1, 2, 3, 4 },
{ 25, 6, 7, 8 },
{ 9, 10, 11, 12 },
System.out.println(findMax(mat)) ;
class array {
maxElement = mat[i][j];
return maxElement;
}}
PROGRAM NO# 5
public static void main(String[] args) {
String password;
do {
if (password.length()<8)
valid = false;
continue;
char c = password.charAt(i);
valid = true;
else
valid = false;
break;
}
} while(!valid);
System.out.println("Password Accepted");
PROGRAM NO# 6
class Fibonacci {
void method(){
int n , t1 = 0, t2 = 1;
n=s.nextInt();
t1 = t2;
t2 = sum;
PROGRAM NO# 7
public static void main(String[] args) {
String name=input.next();
String direction=input.next();
int postion=input.nextInt();
String m;
while (true){
m=input.next();
c.move(m.charAt(0));
if(m.equalsIgnoreCase("S")){
break;
String name;
char direction;
int position;
name = "N/A";
String direction="N/A" ;
for (int i = 0; i < dirP.length; i++) {
dirP[i] = 0;
position = 0;
public Car(String name, char direction, int position) { // Four argument constructor
this.name = name;
this.direction = direction;
this.position = position;
this.direction = direction;
if (m == 'w' || m == 'W'){
dirP[0]++;
setDirection('N');
dirP[1]++;
setDirection('W');
dirP[2]++;
setDirection('E');
display();
else {
System.out.println("Invalid direction!");
}
System.out.println("Name: "+name);
System.out.println("Direction: "+direction);
System.out.println("You have moved " + dirP[0] + " points in the north direction, " +
dirP[1] + " points in west and " + dirP[2] + " points in east direction and " + dirP[3] +"
points in the South.");
for(int i=0;i<dirP.length;i++) {
PROGRAM NO# 8
public static void main(String[] args) {
x[i] = s.nextInt();
temp = x[i];
x[i] = x[j];
x[j] = temp;
System.out.print(x[number - 1]);
PROGRAM NO# 9
class Book {
int BookId;
int Pages;
int Price = 0;
BookId = x;
Pages = y;
Price = z;
int showBookId() {
return BookId;
int showPages() {
return Pages;
int getsPrice() {
return Price;
PROGRAM NO# 10
public static void main(String[] args) {
x.input();
x.show();
x.total();
x.average();
class results {
int i, total;
RollNumber = s.nextInt();
System.out.println("Enter Name");
Name = s.next();
Score[i] = s.nextInt();