External Program Outputs
External Program Outputs
/** Develop a program to display all the even numbers between 1 to 20 using for loop and if statement
*/
classexteven
for(int i=1;i<20;i++)
if(i%2==0)
System.out.print("\t"+i);
/** Develop a Program to create a class Student with data members student_name, roll_no and branch.
class Student
{
String student_name="Srushti",branch="Syco";
introll_no=60;
void display()
s.display();
//extstud.java
*************************************************************************************
importjava.util.*;
classextpalinstring
{
public static void main(String arg[])
original = sc.nextLine();
if (original.equals(reverse))
else
//extpalinstring.java
************************************************************************************
/** Define an exception called 'No match Exception'that is thrown when a string is not equal to
"MSBTE". Write program */
importjava.util.*;
import java.io.*;
String str;
NoMatchException(String a)
super(a);
return " Invalid String (No Matched Found With MSBTE String) "+str;
classextnomatchexc
String str;
str=sc.next();
if(!str.equals("MSBTE"))
{
try
catch(Exception e)
System.out.print(e);
else
*************************************************************************************
-------------------------------------------------
Srushti.txt file
hello!!!!!
--------------------------------------------------
import java.io.*;
intcharCount = 0;
try
currentLine = reader.readLine();
}
System.out.println("Number Of Chars In A File : "+charCount);
catch (IOException e)
e.printStackTrace();
finally
try
reader.close();
catch (IOException e)
e.printStackTrace();
*************************************************************************************
/** Define a Package Named "myPackage"to include a class named "DisplayMsg" with one method to
display some message. Develop a program to import this package in a java application and call the
method difined in the package */
Package myPackage;
Import myPackage.displayMsg;
dm.display();
}
***********************************************************************************
/** Write a program to input name and age of person and throws user defined exception, if entered age
is negative. */
Import java.util.*;
import java.io.*;
int age;
NegativeAgeException(int a)
age=a;
classextageexc
int age;
String nm=sc.next();
System.out.print("\n Enter Your Age :- ");
age=sc.nextInt();
if(age<0)
try
catch(NegativeAgeException ne)
System.out.print(ne);
else
}
*************************************************************************************
/** Write a program to create two threads so one thread will print ascending numbers whereas second
thread will print descending numbers between sequence 1 to 15 numbers */
for(int i=1;i<15;i++)
System.out.print("\t"+i);
for(int i=15;i>1;i--)
System.out.print("\t"+i);
classextthread
{
public static void main(String arg[])
a.start();
d.start();
/** Develop a program to create an applet to display the message "Welcome to the worlds of Applet
"with green color background and red color foreground.*/
Import java.applet.*;
Import java.awt.*;
setBackground(Color.green);
setForeground(Color.red);
**********************************************************************************
/**Develop a program to copy the contents of the file "abc.txt"into a new file "xyz.txt"*/
------------------------------------------------------------------------------------------------
Hello !!!!
------------------------------------------------------------------------------------------------
import java.io.*;
class extcopyfile
int b;
do
b=fin.read();
fout.write(b);
}while(b!=-1);
import java.util.*;
class extsumdigit
num=sc.nextInt();
while(num>0)
digit=num%10;
sum=sum+digit;
num=num/10;
}
*************************************************************************************
import java.util.*;
class extfibonacci
int n1=0,n2=1,n3,count=0,i;
System.out.print("\n How much numbers you've required into the series ?(Enter total count) :- ");
count=sc.nextInt();
System.out.print(n1+"\t"+n2);
for(i=2;i<count;++i)
n3=n1+n2;
System.out.print("\t"+n3);
n1=n2;
n2=n3;
}
*************************************************************************************
/**Write a program to create a vector with seven elements as [10,20,50,20,40,10,20]. Remove element
at 3rd and 4th position. Insert new element at 3rd position. Display the original and current size of the
vector.*/
import java.util.*;
class extvector
v.addElement(new Integer(10));
v.addElement(new Integer(20));
v.addElement(new Integer(50));
v.addElement(new Integer(20));
v.addElement(new Integer(40));
v.addElement(new Integer(10));
v.addElement(new Integer(20));
v.removeElementAt(3);
v.removeElementAt(4);
v.insertElementAt(new Integer(30),3);
**********************************************************************************
/**Write a program to accept a number as command line argument and print the number is even or
odd. */
import java.util.*;
class extcmdeven
String s1=arg[0];
int n=Integer.parseInt(s1);
if(n%2==0)
{
else
**********************************************************************************
/** create an applet to display the string " Applet Graphics Programming " with font " Courier New" ,
size :25 points and BOLD + ITALIC. */
import java.awt.*;
import java.applet.*;
}
}
/*
*/
/** Accept any string containing all types of characters and symbols from user and count only number of
digits.*/
import java.io.*;
class extcountstrdigit
int l=sv.length();
ch=sv.toCharArray();
int c=0;
for(int i=0;i<l;i++)
if(Character.isDigit(ch[i]))
c++;
System.out.print("\n ------------------------------------------------");
System.out.print("\n ------------------------------------------------");
**********************************************************************************
import java.util.*;
class extprime
int num,i,count=0;
num=sc.nextInt();
for(i=2;i<=num/2;i=i+1)
if(num%i==0)
count++;
break;
if(num==0||num==1)
else if(count==0)
else
}
*************************************************************************************
Class : Employee
ID, basic */
import java.util.*;
interface Manager
class Person
String name,address;
public void accept()
name=sc.next();
address=sc.next();
int Id,basic;
void getdata()
Id=s.nextInt();
basic=s.nextInt();
class extinterface
emp.accept();
emp.getdata();
emp.salary();
*************************************************************************************
/** Write an applet program that display the logo of Olympic. All the circle are of same radius, assume
the radius.*/
import java.applet.*;
import java.awt.*;
g.setColor(Color.blue);
g.drawOval(50,50,75,75);
g.setColor(Color.black);
g.drawOval(130,50,75,75);
g.setColor(Color.red);
g.drawOval(210,50,75,75);
g.setColor(Color.yellow);
g.drawOval(95,90,75,75);
g.setColor(Color.green);
g.drawOval(175,90,75,75);
/*
</applet>
*/
*************************************************************************
/** Define a class employee with data members as emp_id and salary, Accept data for 5 objects and
print it.*/
import java.util.*;
class employee
int emp_id,salary;
void accept()
emp_id=sc.nextInt();
salary=sc.nextInt();
void print()
{
System.out.print("\n Id = "+emp_id);
class extemp
for(int i=0;i<5;i++)
e[i]=new employee();
e[i].accept();
for(int i=0;i<5;i++)
e[i].print();
}
**********************************************************************************
for(int i=0;i<=20;i++)
System.out.print("\t"+i);
}
class extrunnableinter
t.start();
**********************************************************************************