Sep

09

class MyEx extends Exception{
MyEx(String s){
super(s);
//System.out.println(s);
}
}
class TestMyEx{
public static void main(String args[]){
int i=10;
if(i==10){
try{
throw new MyEx(“MY Exception is raised”);
}
catch(MyEx e){
System.out.println(e);
}
}
System.out.println(i);
}
}

Sep

08

//——————————– PROGRAM -1 ————————————-

#include<iostream.h>
class A{
public:
void af1(){
cout<<“af1() called from B”;
}
};
/*class B:A{
};*/
/*class B:protected A{
};*/
class B:public A{
};
void main(){
B b1;
b1.af1();
}

//———————————————– PROGARM – 2—————————————

#include<iostream.h>
class A{
protected:
void af1(){
cout<<“af1() called from A”<<endl;
}
};
class B:public A{
public:
void bf1(){
af1();
cout<<“bf1() called from B”<<endl;
}
};
void main(){
B b1;
//b1.A::af1();
b1.bf1();
}

//———————————————– PROGRAM -3 ————————————-

#include<iostream.h>
class A{
protected:
void af1(){
cout<<“af1() called from A”<<endl;
}
};
class B:public A{
public:
void af1(){
A::af1();
cout<<“af1() called from B”<<endl;
}
};
void main(){
B b1;
//b1.A::af1();
b1.af1();
}

//—————————————– PROGRAM – 4—————————————————–

#include<iostream.h>
class A{
public:
/*A(){
cout<<“A() cons called”<<endl;
}*/
};
class B:public A{
public:
B(){
cout<<“B() cons called”<<endl;
}
};
void main(){
B b1;
}

//—————————————- PROGRAM -5 —————————————

#include<iostream.h>
class A{
public:
A(){
cout<<“A()”<<endl;
}
A(int n){
cout<<“A(int n) cons called”<<endl;
}
};
class B:public A{
public:
B(){
A(30);
cout<<“B() cons called”<<endl;
}
};
void main(){
B b1;
}

May

04

File Handling in C Programs-1

Apr

21

Structure program in C – 1

Apr

20

Confirmation and deletion featured have been added

JSP Sample Project-1 (Partial Code-2)

Apr

18

JSP Sample Project-1 (Partial Code)

Apr

12

12.04.2017

Comments Off on JSP Beginner Code-4 (12.04.2017)

Apr

06

JSP Beginner Code-3

Mar

30

JSP Beginner Code-2

Mar

30

//concat strings
#include<stdio.h>
void main(){
char st1[50],st2[50],st3[100];
int i,j;
printf(“Enter First string: “);
gets(st1);
printf(“Enter First string: “);
gets(st2);
for(i=0;st1[i]!=’\0′;i++){
st3[i]=st1[i];
}
j=i;
for(i=0;st2[i]!=’\0′;i++){
st3[j]=st2[i];
j++;
}
//puts(st3);
}

Mar

30

//reverse strings
#include<stdio.h>
void main(){
char st1[100];
int i,j;
printf(“Enter First string: “);
gets(st1);

for(i=0;st1[i]!=’\0′;i++);
for(j=i-1;j>=0;j–){
printf(“%c”,st1[j]);
}
}

Mar

30

//compare strings
#include<stdio.h>
void main(){
char st1[100],st2[100];
char ch;
int i,j,k,flg=0;
printf(“Enter First string: “);
gets(st1);
printf(“Enter Second string: “);
gets(st2);
for(i=0;st1[i]!=’\0′;i++);// to get the length of st1
for(j=0;st2[j]!=’\0′;j++);// to get the length of st2
if(i==j){
for(k=0;k<i;k++){
if(st1[k]!=st2[k]){
flg=1;
break;
}
}
if(flg==0)
printf(“Both Strings are same”);
else
printf(“Both Strings are not same”);
}
else{
printf(“Both Strings are not same”);
}
}

Mar

30

/*
HELLO
HELL
HEL
HE
H
*/

#include<stdio.h>
void main(){
char st[100];
char ch;
int i,j,k;
printf(“Enter a string: “);
gets(st);
for(i=0;st[i]!=’\0′;i++);
for(j=i-1;j>=0;j–){
for(k=0;k<=j;k++){
printf(“%c”,st[k]);
}
printf(“\n”);
}
}