Académique Documents
Professionnel Documents
Culture Documents
Declaration:
I declare that this assignment is my individual work. I have not copied from any other
student’s work or from any other source except where due to acknowledgement is made
explicitly in the text, nor has any part been written for me by another person.
Evaluator’s Comments:
__________________________________________________________________
Ans:-2)Write a program that inputs a sentence at runtime and prints the number of
occurrences of each vowel in it. Further the program must also print the word by word
reverse of the sentence.
Example: If the input string is “What is True in World”, then the output would
be as follows:
VOWEL COUNT
A 1
E 1
I 2
O 1
U 1
The word-wise Reverse is: TAHW SI EURT NI DLROW
Ans: -
}
try
{
sleep(1000);
}
catch(Exception e)
{
}
}
}
Class XYZ
{
Public static void main(String args[])
{
Recursion r= new recursion();
r.start();
}
}
Ques:-5)Develop a program that uses two threads called EvenThread and OddThread.
EvenThread prints the first 10 even numbers whereas OddThread displays the first 10
odd numbers.
Ans: -
import java.lang.Thread;
class EvenThread extends Thread
{
public void show()
{
System.out.println(“Even thread started..”);
}
Public void run()
{
Show();
for(int i=1;i<=10;i++)
{
If(i%2==0)
System.out.println(“Even no.=”+i);
}
}
}
class OddThread implements Runnable
{
public void run()
{
for(j=1;j<=10;j++)
{
if(j%2!=0)
{
System.out.println(“Odd thread started..”);
System.out.println("Odd number= "+j);
}
}
}
}
class EvenOddThread
{
public static void main(String args[])
{
EvenThread eth= new EvenThread();
eth.start();
OddThread oth = new OddThread();
Thread th=new Thread(oth)
th.start();
}
}
System.out.println(“Number of arguments=”+n);
While(i<n)
{
System.out.print(args[i]+"\t");
i++;
}
}
catch(MissingArgumentException e)
{
System.out.println(“Output is:”);
System.out.println(e.getMessage());
}
Finally
{
System.out.println(“Closing of the programme”);
}
}
}