rtc project in table format

select * from ticketheader ;

FLEET_ID TICKET_NO DOI DOT
---------- ---------- --------- ---------
1 1 10-APR-96 10-MAY-96
2 2 12-APR-96 05-MAY-96
3 3 21-APR-96 15-MAY-96
4 4 25-APR-96 25-MAY-96
5 5 30-APR-96 22-MAY-96

using exception using rtc

declare
fleet number(3);
d date;
route number(4);
code number(4);
e number(4):=&e;
cantravel exception;
cantravel1 exception;
cantravel2 exception;
begin
select fleet_id,day,route_id,cat_code into fleet,d,route,code from fleet_header where fleet_id=e;
if d='24-jun-96' then
raise cantravel;
elsif d='20-apr-96' then
raise cantravel1;
elsif d='25-jun-96' then
raise cantravel;
end if;
exception when cantravel then
dbms_output.put_line(d);
when cantravel1 then
dbms_output.put_line(d);
when cantravel2 then
dbms_output.put_line(d);
end;
/

rtc using exception

declare
origin1 varchar2(10);
ticketno number(4);
e1 number(10):=&e1;
chen exception;
ban exception;
begin
select origin,ticket_no into origin1,ticketno from tick_header where ticket_no =e1;
if origin1='chennai' then
raise chen;
elsif origin1='banglore' then
raise ban;
end if;
exception
when chen then
dbms_output.put_line(origin1||' '||ticketno);
when ban then
dbms_output.put_line(origin1||' '||ticketno);
end;
/

rtc project in exception

declare
catcode number(5);
catdesc varchar2(15);
e1 number(7):=&e1;
first exception;
second exception;
begin
select cat_code,cat_desc into catcode,catdesc from category_header where cat_code=e1;
if catcode=1 then
raise first;
elsif catcode=5 then
raise second;
end if;
exception when first then
dbms_output.put_line(catdesc);
when second then
dbms_output.put_line(catdesc);
end;
/

rtc project in exception

declare
catcode number(5);
catdesc varchar2(15);
e1 number(7):=&e1;
first exception;
second exception;
begin
select cat_code,cat_desc into catcode,catdesc from category_header where cat_code=e1;
if catcode=1 then
raise first;
elsif catcode=5 then
raise second;
end if;
exception when first then
dbms_output.put_line(catdesc);
when second then
dbms_output.put_line(catdesc);
end;
/

rtc project in cursors 1

rtc project in cursor

declare
cursor c1 is select t.fleet_id,t.ticket_no,u.total_fare,u.route_id from ticket_header t,ticket_header3 u;
r1 c1%rowtype;
begin

dbms_output.put_line('z.fleet_id ticket_no total_fare route_id' );

for z in c1 loop
exit when c1%notfound;
dbms_output.put_line(z.fleet_id||' '||z.ticket_no||' '||z.total_fare||' '||z.route_id );
end loop;
end;
/

rtc project

declare
cursor c1 is select * from route_header where route_id=&v_route_id;
--r1 c1%rowtype;
v_distance route_header.distance%type;
v_route_id route_header.route_id%type;
begin
for z in c1 loop
exit when c1%notfound;
if v_distance<500 then
update route_header set fare=198.98 where route_id=v_route_id;
elsif v_distance>501 and v_distance<=1000 then
update route_header set fare= 876.98 where route_id=v_route_id;
elsif v_distance>1000 then
dbms_output.put_line('fare is fixed');
end if;
end loop;
end;
/

oracle project 3

procedure fundtransfer(a number,a1 number,b number)
is
cursor c1 is select * from cust_det where cin=a;
cursor c2 is select * from cust_det where cin=a1;
begin
select balance into bal1 from cust_det where cin=a;
select minbal into mb1 from bank_master;
select count(*) into fw from transactions where cin=a and to_char(tdate)=to_char(sysdate) and txntype='w';

if(bal1>b) && (bal1>=mb1) then

for i in c1 loop
exit when c1%notfound;
dbms_output.put_line('previous balance is'||' '||i.balance);
update cust_det set bal=i.bal-b where cin=a;
select balance into z from cust_det where cin=a;
dbms_output.put_line('current balance is'||' '||z);
insert into transactions values(i.cin,i.transdate,i.txnbal);

for i in c2 loop
exit when c2%notfound;
dbms_output.put_line('previous balance is'||' '||i.bal);
update bank_details set bal=i.bal+b where cin=a1;
select bal into z from bank_details where cin=a1;
dbms_output.put_line('current balance is'||' '||z);
end loop;
end loop;
else
dbms_output.put('insufficient funds');
end fundtransfer;

end transactions;
/

oracle project 2

-----------------------------------------------------------------------------------------------------------
customer account sanction :=
---------------------------------------------------------------------------------------------------------------
create sequence loactno start with 2000000000000001 increment by 1 maxvalue 2000000000000010;

create table cust_det5077 (cin number(10),custactno number(10),csurname varchar2(8),cname varchar2(12),cadd varchar2(10),dos date default sysdate,balance number(10,3),status_flag char(1));


create or replace procedure custsan (cin1 number)

is
v_cin number;
v_csurname varchar2(8);
v_cname varchar2(12);
v_cadd varchar2(10);
v_balance number;
act char(1);

v_cin cust_reg.cin%type;
cursor c1 is select cin from cust_reg5077;
invalidcin exception;
begin
v_cin:=cin1;
select count(*) into a from cust_reg where cin=cin1;
for z in c1 loop
if a>=1 then

select active into act from bank_master;
select csurname,cname,cadd,minbal into v_csurname,v_cname,v_cadd,v_balance from cust_reg5077 where cin=v_cin;
insert into cust_det5077 (cin,custactno,csurname,cname,cadd,balance,status_flag)
values(cinseq.currval,actno.nextval,v_csurname,v_cname,v_cadd,v_balance,act);

exit when c1%found;

else
raise invalidcin;
end if;
end loop;
exception when invalidcin then
dbms_output.put_line('cin number is invalid');
end;
/
---------------------------------------------------------------------------------------------------------------


transaction of a customer:=deposit,withdraw,balance enquiry.
------------------------------------------------------------------------------------------------------------------
create table transaction(cin number(17),transdate date,txnbal number(10,3);


create or replace package transactions
as
z number;
mt number;
b1 number
mb number;
x1 number
tw1 char(1);
mb1 number;
tf number;
procedure balance(a number);
procedure withdraw(a number,b number);
procedure deposit(a number,b number);
procedure fundtransfer(a number,a1 number,b number);

end;
/
create or replace package body transactions
as
procedure balance(a number)
is
cursor c1 is select * from cust_det5077 where cin=a;
begin
dbms_output.put_line(cardno||' '||transdate||' '||transactionbal);
for i in c1 loop
exit when c1%notfound;
dbms_output.put_line(i.cin||' '||i.transdate||' '||i.txnbal);


end loop;
end balance;

procedure withdraw(a number,b number)
is

cursor c1 is select * from cust_det where cin=a;
begin
select mintrans,tw,minbal into mt,tw1,mb from bank_master;
select count(*) into x1 from transactions where cin=a and tw='w' and to_char(transdate)=to_char(sysdate);
select balance into bal1 from cust_det5077 where cin=a;

if (x1<=mt) && (bal1>=mb) then
for i in c1 loop
exit when c1%notfound;
update cust_det set bal=i.balance-b where cin=a;
dbms_output.put_line('updated');
dbms_output.put_line('prevoious balance is'||' '||i.balance);
select balance into z from cust_det where cin=a;
dbms_output.put_line('current balance is'||' '||z);
insert into transactions values(i.cin,sysdate,z,td1);
dbms_output.put_line('inserted into transations');
end loop;
else
dbms_output.put_line('daily limit exceeded');
ens if
end withdraw;


procedure deposit(a number,b number)
is

cursor c1 is select * from cust_det where cin=a;
begin
select deposit into b1 from bank_master;
if(b>=b1) then

for i in c1 loop
exit when c1%notfound;
update cust_det5077 set bal=i.balance+b where cin=a;
dbms_output.put_line('updated');
dbms_output.put_line('prevoious balance is'||' '||i.balance);
select balance into z from cust_det5077 where cin=a;
dbms_output.put_line('current balance is'||' '||z);
insert into transactions values(i.cin,i.transdate,i.txnbal);
end loop;
else
dbms_output.put_line('deposit minimum of 10000 for further transactions');
end if;
end deposit;

oracle project1

customer registration:-
--------------------------
create sequence cinseq increment by 1 start with 8000000000000001 maxvalue 8000000000000010;

create table cust_reg(cin number(17),csurname varchar2(8),cname varchar2(12),cdob date,cproofs varchar2(10),cadd varchar2(10),surity_name varchar2(15),doreg date default sysdate,minbal number(10,3),status_flag char(1));


create or replace trigger updatebal
before update or insert on custreg
for each row
begin
if(:new.minbal<=5000) then
raise_application_error(-20999,'bal cant be less than 5000');
end if;
end;
/


create or replace procedure custreg
is
inact char(1);
minb number(8);
begin
select inactive,minbal into inact,minb from bank_master;
insert into cust_reg(cin,csurname,cname,cdob,cproofs,cadd,surity_name,minbal,status_flag)
values(cinseq.nextval,'&csurname','&cname','&cdob','&cproofs',&cadd','&surity_name',minb,inact);
end;
/

few programs on bank project

12.create or replace procedure atmtxns5064 as
cursor c1 is select * from daily_transactions5064 where withdraw <>0;
t daily_transactions5064%rowtype;
begin
open c1;
loop
fetch c1 into t;
exit when c1%notfound;
dbms_output.put_line('Card No: '||t.cardno ||'Tran Date: '||t.trandate|| 'Balance : '||t.balance||'Withdraw'||t.withdraw);
end loop;
dbms_output.put_line('');
close c1;
end;
/
13.create or replace procedure postrans5064 as
cursor c1 is select * from daily_transactions5064 where withdraw<>0;
t daily_transactions5064%rowtype;
begin
open c1;
dbms_output.put_line('');
loop
fetch c1 into t;
exit when c1%notfound;
dbms_output.put_line('Transaction Ref Number: '||t.txn_ref_no ||'Customer Number: '||t.cardno ||'Transaction Type: Pos Amount: '|| t.withdraw || 'Transaction Date: '||t.trandate);

end loop;
dbms_output.put_line('');
close c1;

end;
/

14.create or replace procedure moretxns5064 as
cursor c1 is select cardno,count(trandate) from daily_transactions5064 group by cardno having count(trandate)>=2;
--t daily_transactions5064%rowtype;
--t1 customer_master5064%rowtype;
cdno daily_transactions5064.cardno%type;
cou number;
begin
open c1;
dbms_output.put_line('');
loop
fetch c1 into cdno,cou;
exit when c1%notfound;
--dbms_output.put_line('Customer Identification Number: '||t.cin ||'Customer Number: '||t.accno ||'Customer Name: '||t.custname ||'Account Opening Date: '|| t.opdate || 'Opening Balance: '||t.opbal|| 'Balance : '||t.balance);
dbms_output.put_line('Card Number: '||cdno);
end loop;
dbms_output.put_line('');
close c1;

end;

customer identification number

create or replace procedure abovelakh5064 as
cursor c1 is select * from customer_master5064 where balance>100000;
t customer_master5064%rowtype;
begin
open c1;
dbms_output.put_line('');
if (c1%rowcount<=0) then
dbms_output.put_line('No Customers Available Balance Above 100000');

end if;
loop
fetch c1 into t;
exit when c1%notfound;
dbms_output.put_line('Customer Identification Number: '||t.cin ||'Customer Number: '||t.accno ||'Customer Name: '||t.custname ||'Account Opening Date: '|| t.opdate || 'Opening Balance: '||t.opbal|| 'Balance : '||t.balance);

end loop;
dbms_output.put_line('');
close c1;
end;
/

bank programs

create or replace procedure postxns as
acno number:=&acno;
pamt number:=&pamt;
cou number;
cid varchar2(16);
bal number;
cdno varchar2(16);
pdt date:=&pdt;
bal1 number;
txnno number;
begin


select count(*) into cou from customer_master where accno=acno;
select cin,balance into cid,bal from customer_master where accno=acno;
select cardno into cdno from card_master where cin=cid;
bal1:=bal;
if(cou>0) then
if bal>pamt then
select to_char(pdt,'ddmmyyyyhhmiss')||transeq.nextval into txnno from dual;
bal1:=bal1-pamt;
dbms_output.put_line('bal1:'||bal1||cdno||pdt||pamt||txnno);
insert into daily_transactions values(cdno,pdt,bal1,0,pamt,txnno);
update customer_master set balance=bal-pamt where cin=cid;
commit;
--update daily_transactions set pos=tamt where cardnoo=cdno;
dbms_output.put_line('Account Balance Updated');
else
dbms_output.put_line('Insufficient Funds');
end if;
else
dbms_output.put_line('Account Number Does Not Exist');
end if;
end;
/

min balance program in oracle

create or replace procedure mini as
acno number:=&acno;
txnno varchar2(20);
mdate date:=&mdate;
cou number;
cdno varchar(16);
cid number;
bal number;
v daily_transactions%rowtype;
cursor c1 is select * from daily_transactions where cdno=(select cardno from card_master5064 where cin=(select cin from customer_master where accno=acno));

begin
select count(*) into cou from customer_master where accno=acno;
select cin,balance into cid,bal from customer_master where accno=acno;
select cardno into cdno from card_master where cin=cid;
if(cou>0) then
open c1;
loop
fetch c1 into v;
exit when c1%notfound;

dbms_output.put_line(v.cardno||v.trandate||v.balance||v.deposit||v.withdraw);
end loop;
close c1;

dbms_output.put_line('Total Balance Is:'||bal);
select to_char(mdate,'ddmmyyyyhhmiss')||transeq.nextval into txnno from dual;
insert into daily_transactions values(cdno,mdate,bal,0,0,txnno);
commit;

else
dbms_output.put_line('Account Number Does Not Exist');
end if;

cards balance

.create or replace procedure balance as
acno number:=&acno;
txnno varchar2(20);
bdate date:=&bdate;
cou number;
cdno varchar(16);
cid number;
bal number;
begin
select count(*) into cou from customer_master where accno=acno;
select cin,balance into cid,bal from customer_master where accno=acno;
select cardno into cdno from card_master where cin=cid;
if(cou>0) then
select to_char(bdate,'ddmmyyyyhhmiss')||transeq.nextval into txnno from dual;
insert into daily_transactions values(cdno,bdate,bal,0,0,txnno);
commit;
dbms_output.put_line('Your Account Balance is '||bal);
else
dbms_output.put_line('Account Number Does Not Exist');
end if;
end;
/

real time programs in bank project

create or replace procedure depo
as
acno number:=&acno;
damt number:=&damt;
txnno varchar2(20);
ddate date:=&ddate;
cou number;
cdno varchar(16);
cid number;
opb number;
begin
select count(*) into cou from customer_master where accno=acno;
select cin,opbal into cid,opb from customer_master where accno=acno;
select cardno into cdno from card_master where cin=cid;
if(cou>0) then
select to_char(ddate,'ddmmyyyyhhmiss')||transeq.nextval into txnno from dual;
opb:=opb+damt;
insert into daily_transactions values(cdno,ddate,opb,damt,0,txnno);
update customer_master set balance=balance+damt where accno=acno;
commit;
else
dbms_output.put_line('Account Number Does Not Exist');
end if;
end;
/

real time registration example

1.create or replace procedure register
as
name varchar2(10):=&name;
opamt number:=&opamt;
add1 varchar2(10):=&add1;
ph number:=&ph;
opdate date:=&opdate;

begin
if(opamt>5000) then
insert into customer_master values(name,cust64.nextval,acc64.nextval,opamt,add1,ph,opdt);
commit;
else
dbms_output.put_line('Amount should be greater then 5000');
end if;
end;
/

Creation of tables in oracle

1. create table customer_master(custname varchar2(10),cin number(10)constraint con_pk primary key,accno number(10),opbal number(10),address varchar(10),phno number(10),opdate date);


2.create table card_master(cin number(10),cardno varchar2(16));
alter table card_master add constraint con_fk foreign key(cin) references customer_master5064(cin);
alter table card_master add constraint cad_pk primary key(cardno);

3) create table daily_transactions(cardno varchar2(16),trandate date,tranamt number(10),balance number(10),deposit number(10),withdraw number(10),txn_ref_no varchar2(20));
alter table daily_transactions add constraint txn_fk foreign key(cardno)references card_master5064(cardno);
alter table daily_transactions5064 add constraint txn_pk primary key(TXN_REF_NO);

insert into customer_master values('&custname',cust64.nextval,acc64.nextval,&opbal,'&address',&phno,'&opdate');

insert into card_master values(1111122222,cdno64.nextval);

practice quries

11)Find the day of the week on which Smith joined .
a)select ename,hiredate ,extract(day from hiredate) from emp where ename like'SMITH';


12)Find out the time of the day in(hh24:mi:ss) on which “Ford” joined the company.

a) select to_char(to_date(hiredate,'dd-mon-yy'),'hh24:mi:ss') from emp where ename like 'FORD';


13)Retrieve the analyst record with the hire date formatted as the 3rd,December,1994.
a)select job,hiredate , to_char(to_date(hiredate,'dd-mon-yy'),'DDTH,month,yyyy')from emp where job like 'ANALYST';

14)Find the day of week on which Smith joined .
a)select ename,hiredate ,extract(day from hiredate) from emp where ename like'SMITH';
select to_char(to_date(hiredate,'dd-mon-yy'),'DAY') from emp where ename like'SMITH';


15)How many months has the president worked for the company .round the nearest whole number of months.
a) select job,round(months_between(sysdate,hiredate)) from emp where job ='PRESIDENT';


16) Write a query to display rows from emp table , if empno contains digit 2.
a) select * from emp where empno like '%2%';


17) write a query to display greatest date 12-jun-99,17-mar-99,13-jun-99.
a)select greatest('12-jun-99','17-mar-99','13-jun-99') from dual;


18) Write a query to display next Monday date and find the size of the date
a)select next_day(sysdate,'monday') from dual;


19) Write a query for making the all initial letters of the give string
“yalamanchili school of learning located in the diamond park junction and beside the sai ram parlour”. In caps.;
a)select initcap('yalamanchili school of learning located in the diamond park junction and beside the sai ram parlour') from dual;

20) Raise the salary of emp Adams.
a)update emp set sal=sal+1000 from emp where ename='ADAMS';


21)Write a query to display the details of all employees who earn salary greatest than the average salary.
a)select sal from emp where sal>any(select avg(sal) from emp);

22)Determine the employee in Scott department and also have worked in sales.


23)Write a sub query to display max salary from emp table.
a) select * from( select ename,sal from emp order by sal desc) where rownum<2;


24) Write a query to display details of employees in dept no 20 , who have the same job some one in sales dept has as well.
a) select sal,ename from emp where deptno=20 and job='SALESMAN';



25)Product a list of jobs for departments 10,20,50 in that order . Display job id, and dept id using set operates.
a)

26)Display last name ,job and salary for all employees whose job is sales representatives or stock clerk and salary is not equal to 2500 ,3500 0r 7000.
a)select ename,job from emp where job in(sales,representative,stockclerk)and salary not in(2500,3500,7000);

27)WAQ to display employees getting first two least salaries.
a)select * from(select sal from emp order by sal desc) where rownum<2;

28) WAQ to display employees working in smith's department.
a)select * from emp where deptno=(select deptno from emp where ename like 'SMITH');

quries

1) Give the details of employees who have been hired between 09-JUN-81 And 31-DEC-04.
a) select * from emp where hiredate between '09-JUN-81' And 31-DEC-04


2)Write a query to display dept no , lowest salary and highest salary in each department.
a) select deptno,min(sal),max(sal) from emp group by deptno;


3)Write a query to display the tomorrow date and next week date.
a)select sysdate+1,next_day(sysdate,'saturday') from dual;


4)Write a query to display the dates for one day after and one day before.
a)select sysdate+1,sysdate-1 from dual;


5)Write a query to display the system date and previous date.
a)select sysdate,sysdate-1 from dual;

6) Write a query to display the current date and time.
a)select to_char(to_date(sysdate,'dd-mm-yyyy'),'dd-hh24:mi:ss') from dual;


7)List the names, dept of all employees whose hire date anniversary does exits in the first quarter of the year.
a)select ename,deptno where to_char(hiredate,'q')<>1;

8)Find Century in which BALKE joined.
a)select to_char(hiredate,'cc') from emp where ename='BLAKE';


9)Find out which quarter of the year the employees joined.
a)select to_char(hiredate, 'q') from emp;

10)List the names and hire date of the employees in dept no 20, display hire date formated as 12/03/1984.
a) select to_char(hiredate,'dd/mm/yyyy') from emp where deptno=20;

reverse number

class reverse
{ static int n,val,r;
public static void main(String args[])
{
n=Integer.parseInt(args[0]);

while(n!=0)
{
r=(n % 10);
val=10*r+r;

}
System.out.println(val);

}

}

throws exception

class exe18 extends Exception
{
private int detail;
exe18()
{
System.out.println("default");
}

exe18(int detail)
{
this.detail=detail;
}

public String toString()
{
return"myexception["+detail+"]";
}


static void compute(int detail) throws exe18
{
System.out.println("called compute("+detail+")");
if(detail>10)
throw new exe18(detail);
System.out.println("normal exit");
}
}
class exe19
{
public static void main(String args[])
{

try
{
exe18.compute(8);
exe18.compute(54);
}
catch(exe18 e)
{
System.out.println("caught "+e);
System.out.println(e.toString());
}
}
}

throws exception

class exe18 extends Exception
{
private int detail;
exe18()
{
System.out.println("default");
}

exe18(int detail)
{
this.detail=detail;
}

public String toString()
{
return"myexception["+detail+"]";
}


static void compute(int detail) throws exe18
{
System.out.println("called compute("+detail+")");
if(detail>10)
throw new exe18(detail);
System.out.println("normal exit");
}
}
class exe19
{
public static void main(String args[])
{

try
{
exe18.compute(8);
exe18.compute(54);
}
catch(exe18 e)
{
System.out.println("caught "+e);
System.out.println(e.toString());
}
}
}

divide by zero

class exe6
{
static void nestry(int a)
{
try
{

if(a==1)
a=a/a-a;
if(a==2)
{
int[] c=new int[100];
c[100]=100;
System.out.println("this wont come");
}
}
catch(Exception e)
{
System.out.println("array index out of range"+e);
}

}



public static void main(String args[])
{
try
{
int a=Integer.parseInt(args[0]);
int b=21/a;
System.out.println(b);
nestry(a);
}
catch(Exception e)
{
System.out.println("divide by zero"+e);
}

}

}

array index

class exe3
{
public static void main(String args[])
{
try
{
int[] a=new int[100];
a[100]=100;
System.out.println("this wont come");
}
catch(Exception e)
{
System.out.println("array index out of range"+e);
}
System.out.println("after catch");
}
}

length of a string name

class string1
{
public static void main(String args[])
{
String s=new String("ramesh kumar");
String s1="ramesh";
String s5="ramesh";
String s2=new String("RAMESH");
String s3=new String("ramesh");
String s4=new String("ramesh");

System.out.println(s);
System.out.println(s.length());
System.out.println(s.charAt(0));
System.out.println(s.charAt(1));
System.out.println(s.toUpperCase());
System.out.println(s.toLowerCase());
System.out.println(s.startsWith("r"));
System.out.println(s.endsWith("r"));
System.out.println(s1.equals(s2));
System.out.println(s1.equalsIgnoreCase(s2));
System.out.println(s1);
System.out.println(s1.length());
System.out.println(s1.substring(2));
System.out.println(s1+" "+s1);


if(s1==s5)
{
System.out.println("true");
}
else
{
System.out.println("false");

}
}
}

no parameters to string

package mypack;

class condisp1
{
condisp1()
{
System.out.println("no parameters");
}
condisp1(int i)
{
System.out.println("value of i is"+i);
}
condisp1(int k,int j)
{
System.out.println("value of k is"+k);
System.out.println("value of j is"+j);
}
}
class classpack1
{
public static void main(String args[])
{
condisp1 a=new condisp1(5);
condisp1 b=new condisp1(2,1);
condisp1 c=new condisp1();
}
}

print two parameters

class A
{
void show()
{
System.out.println("hai");
}
}
class B extends A
{
void show()
{
System.out.println("friend");
}

}
class samp1
{
public static void main(String args[])
{
/*A oa1;
oa1=new A();
oa1.show();

A oa2;
oa2=new B();
oa2.show();
*/
B oa3;
oa3=new B();
oa3.show();


}
}

abstract class in core java

abstract class A
{
int x1=10;
int x2=20;
static int x3=30;
static void disp()
{
System.out.println(x3);
}
void set(int p1,int p2)
{
x1=p1;
x2=p2;
}
abstract void show();
}
class B extends A
{
int x4=40;
void show()
{
System.out.println(x1);
System.out.println(x2);
System.out.println(x3);
System.out.println(x4);

}
}
class C extends A
{
int x5=50;
int x6=60;
void set(int p1)
{
x1=p1;
}
void set(int p1,int p2)
{
x5=p1;
x6=p2;
}
void show()
{
System.out.println(x1);
System.out.println(x2);
System.out.println(x3);
System.out.println(x6);
}
}
class abs1
{
public static void main(String args[])
{
A.disp();

B ob=new B();
ob.show();

C oc=new C();
oc.show();
oc.set(32);
oc.set(9,5);
oc.show();

A oa1;
oa1=new B();
oa1.set(4,3);
oa1.show();

A oa2;
oa2=new C();
oa2.set(2,5);
oa2.show();

}
}

inside area of rectangle

abstract class figure
{
double dim1;
double dim2;

abstract double area();

void figure1(double a,double b)
{
dim1=a;
dim2=b;
}
}
class rectangle extends figure
{
rectangle(double a,double b)
{
super.figure1(a,b);
}
double area()
{
System.out.println("inside area of rectangle");
return dim1*dim2;
}
}
class triangle extends figure
{
triangle(double a,double b)
{
super.figure1(a,b);
}
double area()
{
System.out.println("inside area of triangle");
return (dim1*dim2)/2;
}
}
class absfig4
{
public static void main(String args[])
{
rectangle r=new rectangle(10,30);
triangle t=new triangle(10,50);

System.out.println("area of rectangle "+r.area());

System.out.println("area of triangle "+t.area());
}
}

area of rectangle

abstract class figure
{
double dim1;
double dim2;

abstract double area();

void figure1(double a,double b)
{
dim1=a;
dim2=b;
}
}
class rectangle extends figure
{
rectangle(double a,double b)
{
super.figure1(a,b);
}
double area()
{
System.out.println("inside area of rectangle");
return dim1*dim2;
}
}
class triangle extends figure
{
triangle(double a,double b)
{
super.figure1(a,b);
}
double area()
{
System.out.println("inside area of triangle");
return (dim1*dim2)/2;
}
}
class absfig2
{
public static void main(String args[])
{
rectangle r=new rectangle(10,30);
triangle t=new triangle(10,50);

System.out.println("area of rectangle "+r.area());

System.out.println("area of triangle "+t.area());
}
}

three string parameters

class con1
{
con1()
{
System.out.println("no parameters");
}
con1(int a)
{
System.out.println("single parameter"+a);
}
con1(int a,double b)
{
System.out.println("two parameters"+a+" "+b);
}
con1(int a,float b)
{
System.out.println("three parameters"+a+" "+b);
}
}
class co
{
public static void main(String args[])
{
con1 x=new con1();
con1 x1=new con1(5);
con1 x2=new con1(5,6.5);
con1 x3=new con1(55,7.5);
}
}

class b extends a

class A
{
void showA()
{
System.out.println("class showA");
}
}

class B extends A
{
void showB()
{
System.out.println("class showB");
}
}

class show
{
public static void main(String args[])
{
A a=new A();
B b=new B();
a.showA();
b.showB();
// a.showB();
b.showA();
}
}

incremeting numbers

class test
{
int a;
test(int i)
{
a=i;
}
test inc()
{
test temp=new test(a+10);
return temp;
}
}
class retobj1
{
public static void main(String args[])
{
test obj1=new test(2);
test obj2=new test(10);
test obj3;
obj3=obj1.inc();
obj3=obj2.inc();
System.out.println("obj1 value is"+obj1.a);
System.out.println("obj2 value is"+obj2.a);
System.out.println("obj3 value is"+obj3.a);
obj2=obj2.inc();
obj3=obj3.inc();

System.out.println("objafter incrementing"+obj2.a);
System.out.println("objafter incrementing"+obj3.a);

}
}

sum of three parameters

class con1
{
con1()
{
System.out.println("no parameters");
}
con1(int a)
{
System.out.println("single parameter"+a);
}
con1(int a,double b)
{
System.out.println("two parameters"+a+" "+b);
}
con1(int a,float b)
{
System.out.println("three parameters"+a+" "+b);
}
}
class co
{
public static void main(String args[])
{
con1 x=new con1();
con1 x1=new con1(5);
con1 x2=new con1(5,6.5);
con1 x3=new con1(55,7.5);
}
}

box program

class box
{
double width;
double height;
double depth;

box(box o)
{
width=o.width;
height=o.height;
depth=o.depth;
}

box(double w,double h,double d)
{
width=w;
height=h;
depth=d;
}
box()
{
width=20;
height=40;
depth=50;
}
box(double x)
{
width=height=depth=x;
}
double volume()
{
return width*height*depth;
}
}

class conoap
{
public static void main(String args[])
{
box mybox1=new box(10,40,20);
box mybox2=new box();
box mycube=new box(8);
box myref=new box(mybox1);
double vol;
vol=mybox1.volume();
System.out.println(vol);

vol=mybox2.volume();
System.out.println(vol);

vol=mycube.volume();
System.out.println(vol);

vol=myref.volume();
System.out.println(vol);
}
}

strings

class test
{
int a,b;
test(int i,int j)
{
a=i;
b=j;
}
void math(test o)
{
o.a*=2;
o.b/=2;
}
}
class oap1
{
public static void main(String args[])
{
test x=new test(10,20);
System.out.println("before call"+x.a+" "+x.b);
x.math(x);
System.out.println("before call"+x.a+" "+x.b);

}
}
Template Design by faris vio