Oops Lab Manual Jan 03, 2024
Oops Lab Manual Jan 03, 2024
OUTPUT:
Hello
OUTPUT:
The oe o fox +e
1a56. 636.
ciC Ie f
2(B)NAME OF THEEXPERIMENT:
I/Enter any number and check whether it is even or odd using If Statement.
import java.util.Scanner;
public class SimplelfDemo{
public static void main(String] args) {
Scanner input =new Scanner(System.in);
System.out.printn("Enter an integer: ");
int number = input.nextInt();
if (number % ==)
System.out.printin("Even");
else
System.out.println("Odd");
}
OUTPUT:
&ntex
integes
odd
Even
OUTPUT:
Gde B
OUTPUT:
Entes n integes (the inat eds if it i5 o)3
©ntes on inte aex(+he in Pot end5 if it is o)!5
Entes an 1Heges Cthe inPt endsiE i+ iS o):6
an inteAex (the int eds iE it iS o).o
enter
EXPERIMENT NO:-3(B)
BANAME OF TIE EXPERIMENT:
long tuctorial 1;
for (int i= 1; i<=num; ++i)
Il factorial = factorial * i;
factorial *= i;
OUTPUT:
foctogil
EXPERIMENT NO:-3( C)
3(C)NAME OF THE EXPERIMENT:
|/Fibonacci Series using while loop.
class Fibo{
public static void main (String [] args)
int i= 1, n = 10, firstTerm = 0, secondTerm = 1:
System.out.println("Fibonacci Series till " +n+" tens:"):
while (i<=n) {
System.out.print(firstTerm + ", "):
it+;
OUTPUT:
fibon acGi Gesies +il lo +exm:
0l,l,2, 3, S, 8,13,2,34
class TestStudent2{
public static void main (String args[]{
Student sl=new Student ():
sl.id=111;
sl.name="Chitta";
System.out.printn(sl.id+" "*sl.name);/printing members with awhite space
}
OUTPUT:
EXPERIMENT NO;-4(B)
OUTPUT:
EXPERIMENT NO:-5(A)
ENGINEERING
class TestBank
public staticvoid main (String args){
Bank b;
b=new SBI ():
System.out.printin("Rate of Interest is: "+b. getRateOfinterest 0 +" %");
b=new PNB (0;
System.out,printn("Rate of Interest is: "+b. getRateOflnterest (0 +" %")%
OUTPUT:
Rote of IntBXe 5+ i5 7.
Ro+e oe Tntexe6t i5:&.
EXPERIMENT NO:-5(B)
class Animal {
void eat ()
{System.out.println('eating.. ");}
class Dog extends Animal
void bark 0
{System.out.printin("barking.."):}
class TestInheritance{
public static void main (String args[){
Dog d-new Dog ();
d.bark0:
d.eat();
}}
OUTPUT:
bozuing.
eoting -
class Animal {
void eat () (System.out.printn("'eating...")}
OUTPUT:
weeeing
bosking
eating- ---
interface Printable {
void print );
interface Showable
void show 0;
OUTPUT:
Helo
welcome
class Bank{
float getRateOfInterest ) {return 0;}
}
class SBI extends Bank {
float getRateOfInterest () {return 8.4f;)
class TestPolymorphism{
public static void main (String args ){
Bank b:;
b=new SBI ();
System.out.println("SBIRate of Interest: "+b,getRateOfinterest():
b=new ICICI ():
System.out.println("1CICI Rate of Interest: "+b. getRateOflnterest ();
b=new AXIS 0;
System.out.printn("AXIS Rate of Interest: "+b. getRateOfinterest ());
OUTPUT:
S8I Rote of TntexeS+ :3-4
IcICI Rote of Inte6e5t : 3
AxIS Rote of Inteze5t 97
OUTPUT:
OUTPUT:
+h Bod 15 Kunn i ng
OUTPUT:
import java.applet.Applet;
import java.awt.Graphics;
publicclass First extends Applet {
OUTPUT:
Caelcome
OUTPUT:
OUTPUT:
333
import java.awt.*;
import java.applet.*;
public class India Flag extends Applet
g.setColor(Color. blue);
g.fillRect(50,20,5,300);
g.setColor(Color.black);
g.drawRect(50, 18,3,300);
g.setColor(Color.orange);
g.fillRect(55,20,120,30);
g.setColor(Color.black):
g.drawRect(55,20,118,28);
g.setColor(Color.green);
g.fillRect(55,80,119,30);
g.setColor(Color.black);
g.drawRect(55,80,117,28);
g.setColor(Color.black);
gdrawOval(100,50,30,30);
<htm|>
<head>
<head>
<body>
<applet code = "IndiaFlag. Class" width ="320" height ="480"></applet>
<body>
<htm>
OUTPUT:
OUTPUT: