# QUE 50 ...please show output also...

Amit
QUE 50 ...please show output also...
37 Answer(s)      6 years and 5 months ago
Posted in : Java Beginners

Q1. Write a program to find maximum and minimum of 3 integers using nested if-else. Read numbers as a command line argument.

Q2. Write a program that prints the prime no between 0 and 100.

Q3. Write a program to determine grade for given marks Marks Grade 80-100 Distinction 60-79 1st Class 40-59 2nd Class Less than 40 FAIL

Q4. Write a program that takes 'n' numbers from user as a command line arguments and prints the maximum and minimum of these numbers using 'for' loops.

Q5. Write a program to check entered no. is Prime or not

Q6. Write a program to split 4 digit no.

Q7. Write a program to for Fibonacci series. (Recursive)

Q8. Write a program to compute sum of the digits of a given integer number

Q9. Write a program to create a menu driven arithmetic calculator. (Use switch-case)

Q10. Write a program to display following patterns:

a) * * * * * * * * * * * * * * *

b) \$ \$ \$ \$ \$ \$ \$ \$ \$ \$ \$ \$ \$ \$ \$

c) * * * *

`````` * * *
*
``````

d) A A B A B C A B C D A B C D E

e) A B C D C B A A B C B A A B A A

f) 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 1 5 10 10 5 1

Q11. Declare a class called Circle with following members. Variables: radius - integer Constructors: 1)Circle() : assign 1 to radius. 2)Circle(int r) : assign the value of r to radius of calling object. Methods: 1) setData(int r) : assign the value of r to radius of calling object. 2) getArea() : calculate and return the area of circle object. 3)print() : print the radius and area of calling object. Write a driver class to test Circle class.

Q12. Construct a class Bank Account with Rs. 500 as the initial balance amount. The class has two methods: deposit(double amount), withdrawal(double amount). Write a program that asks the user for the amount to be deposited and also the amount to be withdrawn and performs the both using the methods of the class BankAccount. There should be a check that the initial amount is not less than Rs. 500.

Q13. Declare a class called Rectangle with following members: Variables: length and breadth - integer Methods: 1) setData(int length, int breadth) : assign a length to length and breadth to breadth of the object 2) setData(int a) : assign a to base and height 3) getArea() : Calculate and return the area of Rectangle object 4) print() : print the length, breadth and area of calling object Write a driver class to test Rectangle class.

Q14. Declare a class called Triangle with following members: Variables: base and height - integer Methods: 1) setData(int base, int height) : assign base to base and height to height of the object 2) setData(int a) : assign a to base and height 3) getArea() : Calculate and return the area of Triangle object 4) print() : print the base, height and area of calling object Write a driver class to test Triangle class.

Q15. Write a program using class Complex to calculate addition of two complex numbers.

Q16. Write a program that finds the average of the numbers stored in a 1-Dimensional array

Q17. Write a program that sorts the elements stored in a one dimensional array

Q18. Write a program to perform matrix addition.

Q19. Write a program to perform matrix multiplication

Q20. Write a program to find maximum and minimum element of the array

Q21. Given a list of marks ranging from 0 to 100. Write a program to compute and print the number of students who have obtained mark a) In the range 81 to 100 b) In the range 61 to 80 c) In the range 41 to 60 d) In the range 0 to 40

Q22. Write a program that displays the marks of 5 subjects of 3 students and the average of marks for each subject

Q23. Write a program to find number of Uppercase, lowercase, blank spaces and digit and special symbols in the entered String

Q24. Write a program to check whether the entered String is palindrome or not

Q25. Write a program to check whether entered Email Id is valid or not

Q26. Write a program that will sort a list of names of 5 cricketers in alphabetical order

Q27. Write a program to capitalize the first character of each word from the given sentence.(For example: watumull institute of engineering ==> Watumull Institute Of Engineering)

Q28. Write a program to perform String reverse operation.

Q29. Write a program to accepts 3 digit number and print it out digit by digit as a series of word. Example: 435 would be printed as "Four Three Five"

Q30. Write a program to count the frequency of a given letter in a String

Q31. Write a program to accept any String up to 15 characters. Display the elements of String with their element nos. use toCharArray() function

Q32. Write a program to declare 2 integers (a & b). Take the input from the user. Declare a float variable c where c=a+b. Handle Exception properly.

Q33. Write a program to declare an array of size specified by the user. Prompt the user to enter array elements and print the same. Handle likely Exceptions.

Q34. Write a program to read a character from the user. If the entered character is a,e,i,o,u then raise the user defined Exception called "VowelException" If the entered character is x or X then raise a user defined Exception called "ExitException" Else print the character 5 times.

Q35. Define an Exception called "NotMatchingException" that is thrown when the string entered by the user as command line arguments is not equal to "India".

Q36. Write an abstract class called Shape. Shape has a constant field called P1. It has 2 abstract methods: area and perimeter. This class has 2 non-abstract sub-classes called Circle and Rectangle. Circle has one additional attribute called radius Rectangle class has 2 additional attributes called width and height Include a client class to test the above classes

Q37. Write a program to declare a vector with initial capacity 5 and increment of 3 a. Add 3 string objects b. Print the content of vector c. Print size and capacity d. Add 4 integer objects in the vector e. Remove the element object present at position2 f. Check whether the vector is empty or not i. If vector is empty, the print a message "empty vector" ii. Else print the capacity, size and vector elements.

Q38. Write a program to find factorial of a number using Recursion

Q39. Write a program that accepts a shopping list of five items from the command line and stores in a vector ad perform the following operations i. Add an item in the list ii. Delete an item in the list iii. Prints the shopping list

Q40. Write a program to create 2 threads. 1st calculating sum of first 5 numbers. 2nd calculating factorial of first five numbers. (By extending Thread class)

Q41. Write a program to create 2 threads. 1st calculating sum of first 5 numbers. 2nd calculating factorial of first five numbers. (Using Runnable interface)

Q42. Write a program to demonstrate following methods of multithreading programs i. sleep() ii. setName() iii. getName() iv. setPriority() v. getPriority()

Q43. Implement the following hierarchy

```                            Saff

Id : int
Name : String
Display()
/             \
/                 \
/                     \

Teacher                   Typist

Subject : String          Speed : int
Display()                 Display()

|
|
|

Contractual

Pay : float
Display()
```

Q44. Write an applet to print "initialization" when applet is initializing. Print "Start" when applet is starting. Print "Stop" when applet is stopped. Print "Destroy" when applet is destroyed. (Applet Life Cycle)

Q45. Write an applet to draw Joker face.

May 1, 2011 at 4:01 PM

May 2, 2011 at 11:34 AM

1)

```import java.util.*;
class LargerNumber{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter Number1: ");
int x=input.nextInt();

System.out.print("Enter Number2: ");
int y=input.nextInt();

System.out.print("Enter Number3: ");
int z=input.nextInt();
if ((x>y)&&(x>z)){
System.out.println(x+" is larger");
}
else if ((y>x)&&(y>z)){
System.out.println(y+" is larger");
}

else if ((z>y)&&(z>x)){
System.out.println(z+" is larger");
}
}
}
```

May 2, 2011 at 11:36 AM

2)

```class PrimeNumbers{
public static void main (String args[]){
String primeNo = "";
int j=0;
System.out.println("Prime nums are:" );
for (int i = 0; i < 100; i++){
for ( j = 2; j < i; j++){
if (i % j == 0) {
break;
}
}
if (i == j) {
primeNo += i + " ";
}
}
System.out.println(primeNo);
}
}
```

May 2, 2011 at 11:44 AM

3)

```import java.util.*;
class IfElse{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter Marks: ");
int marks=input.nextInt();
if(marks>=80&&marks<=100){
System.out.println("Distinction");
}
else if(marks>=60&&marks<=79){
System.out.println("1st Class");
}
else if(marks>=40&&marks<=59){
System.out.println("2nd Class");
}
else{
System.out.println("Fail");
}
}
}
```

May 2, 2011 at 11:47 AM

4)

```import java.util.*;
class  FindLargestAndSmallest{
public static void main(String[] args){
int max = Integer.MIN_VALUE;
int min = Integer.MAX_VALUE;

Scanner input=new Scanner(System.in);
System.out.println("How many numbers you want to input? :");
int n=input.nextInt();
System.out.println("Enter "+n+" numbers: ");
for(int i=1;i<=n;i++){
int num=input.nextInt();
if (num < min) {
min = num;
}
if (num > max) {
max = num;
}

}
System.out.println("Smallest Number is: "+min);
System.out.println("Largest Number is: "+max);
}
}
```

May 2, 2011 at 11:48 AM

5)

```import java.util.*;

{
static boolean isPrime(int number){
boolean isPrime=false;
int i=(int) Math.ceil(Math.sqrt(number));
while (i>1){
if((number!=i) && (number%i==0)){
isPrime=false;
break;
}
else if (!isPrime)
isPrime=true;
--i;
}
return isPrime;
}
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.println("Enter Number:");
int num=input.nextInt();
if(isPrime(num)){
System.out.println("Number is Prime!");
}
else{
System.out.println("Number is not prime!");
}
}
}
```

May 2, 2011 at 12:11 PM

6)

```import java.util.*;
class Split4DigitNumber
{
public static void main(String args[])
{
Scanner input=new Scanner(System.in);
System.out.println("Enter 4 digit number: ");
int x = input.nextInt();
int y, z;

y = x /1000 ;
System.out.println("The digit in the Thousand's place = "+y);

z = x % 1000;
y = z /100;
System.out.println("The digit in the Hundred's place = "+y);

z = z % 100;
y = z / 10;
System.out.println("The digit in the Ten's place = "+y);
y = z % 10;
System.out.println("The digit in the Unit's place = "+y);
}
}
```

May 2, 2011 at 12:30 PM

7)

```import java.util.*;

public class Fibonacci{
public static int fibonacciSeries(int n) {
if (n == 1)
return 1;
else if (n == 2)
return 1;
else
return fibonacciSeries(n-1) + fibonacciSeries(n-2);
}
public static void main(String[] args) throws Exception {
Scanner input=new Scanner(System.in);
System.out.print("Enter value of n: ");
int num = input.nextInt();
for(int i=1;i<=num;i++){
System.out.println(fibonacciSeries(i));
}
}
}
```

May 2, 2011 at 12:33 PM

8)

```import java.util.*;

class SumOfDigits {
public static void main(String args[]) {
int sum = 0;
System.out.println("Enter multi digit number:");
Scanner input = new Scanner(System.in);
int n = input.nextInt();
int t = n;
while (n > 0) {
int p = n % 10;
sum = sum + p;
n = n / 10;
}
System.out.println("sum of the digits in " + t + " is " + sum);
}
}
```

May 2, 2011 at 12:36 PM

9)

```import java.util.*;
class Calculator
{
public static void main(String[] args)
{
boolean exit=false;
Scanner input=new Scanner(System.in);
System.out.print("Enter number1: ");
double num1=input.nextDouble();
System.out.print("Enter number2: ");
double num2=input.nextDouble();
System.out.println("2 Subtraction");
System.out.println("3 Multiplication");
System.out.println("4 Division");
System.out.println("5 Exit");
do{
int choice=input.nextInt();
switch(choice){
case 1:
break;
case 2:
double sub=num1-num2;
System.out.println("Subtraction="+sub);
break;
case 3:
double mul=num1*num2;
System.out.println("Multiplication="+mul);
break;
case 4:
double div=num1/num2;
System.out.println("Division="+div);
break;
case 5:
exit=true;
break;
}
}
while(!exit);
}
}
```

May 2, 2011 at 3:41 PM

10 a)

```public class PatternExample {
public static void main(String[] args) {
int y = 1;
for(int i=5; i>= 1 ;i--){
for(int j=1; j <= i ; j++){
System.out.print(" *");
y = y + 1;
}
System.out.println("");
}
}
}
```

10 b)

```public class PatternExample {
public static void main(String[] args) {
int y = 1;
for(int i=1; i<= 5 ;i++){
for(int j=1; j <= i ; j++){
System.out.print(" \$");
y = y + 1;
}
System.out.println("");
}
}
}
```

10 c)

```public class PatternExample {

public static void main(String[] args) {
int n = 2;

for (int i = -n; i <= n; i++) {
for (int j = -n; j <= n; j++) {
if (Math.abs(i) + Math.abs(j) <= n){
System.out.print("* ");
}
else{
System.out.print("  ");
}
}
System.out.println();
}
}
}
```

10 d)

```public class PatternExample{
public static void main(String[] args){
for(char i='A';i<='E';i++){
for(char j='A';j<=i;j++){
System.out.print(j);
}
System.out.println();
}
}
}
```

May 2, 2011 at 3:54 PM

11)

```class Circle{
static double pi=3.14;

Circle(){
}
}

public void setData(int r) {
}
public double getArea(){
return area;
}
public void print(){
double area=getArea();
}
}
public class TestCircle{
public static void main(String[] args){
Circle c1=new Circle();
c1.print();
c1.setData(5);
c1.print();

Circle c2=new Circle(4);
c2.print();
c2.setData(2);
c2.print();
}
}
```

May 2, 2011 at 4:02 PM

12)

```import java.util.*;
class  BankAccount{
double bal;

BankAccount(int bal) {
this.bal = bal;
}
double deposit(double amt) {
if (amt < 0) {
System.out.println("Invalid Amount");
return 1;
}
bal = bal + amt;
return 0;
}

double withdraw(double amt) {
if (bal < amt) {
System.out.println("Not sufficient balance.");
return 1;
}
if (amt < 0) {
System.out.println("Invalid Amount");
return 1;
}
bal = bal - amt;
return 0;
}
void check() {
}

public static void main(String[]args){
Scanner input=new Scanner(System.in);
BankAccount Cust=new BankAccount(500);
System.out.print("Enter the amount to deposit:");
double dep=input.nextDouble();
double bal1=Cust.deposit(dep);
Cust.check();
System.out.print("Enter the amount to withdraw:");
double with=input.nextDouble();
double bal2=Cust.withdraw(with);
Cust.check();
}
}
```

May 2, 2011 at 4:21 PM

13)

```class Rectangle{
int length;

public void setData(int length,int breadth) {
this.length = length;
}
public void setData(int a) {
length = a;
}
public int getArea(){
return area;
}
public void print(){
System.out.println("Length of triangle is: "+length+" ,Breadth is: "+breadth+", Area of rectangle is: "+getArea());
}
}
public class TestRectangle{
public static void main(String[]args){
Rectangle rect=new Rectangle();
rect.setData(2,3);
rect.print();

rect.setData(5);
rect.print();
}
}
```

May 2, 2011 at 4:27 PM

14)

```class Triangle
{
int base;
int height;

public void setData(int base,int height) {
this.base = base;
this.height=height;
}
public void setData(int a) {
base = a;
height=a;
}
public int getArea(){
int area=base*height;
return area/2;
}
public void print(){
System.out.println("Base of triangle is: "+base+" ,Height is: "+height+", Area of triangle is: "+getArea());
}
}
public class TestTriangle
{
public static void main(String[] args)
{
Triangle tri=new Triangle();
tri.setData(2,3);
tri.print();

tri.setData(4);
tri.print();
}
}
```

May 2, 2011 at 4:31 PM

15)

```public class Complex {
private int a;
private int b;

public Complex () {
}

public Complex (int a, int b) {
this.a = a;
this.b = b;
}

public String getComplexValue() {
if (this.b < 0) {
return a + "" + b + "i";
} else {
return a + "+" + b + "i";
}
}

public static String addition(Complex num1, Complex num2) {
int a1 = num1.a + num2.a;
int b1 = num1.b + num2.b;
if (b1 < 0) {
return a1 + "" + b1 + "i";
} else {
return a1 + "+" + b1 + "i";
}
}

public static void main(String args[]) {
Complex com1 = new Complex (-2, -3);
Complex com2 = new Complex (-4, -5);
System.out.println(com1.getComplexValue());
System.out.println(com2.getComplexValue());
System.out.println("Addition of Complex Numbers are :"

}
}
```

May 2, 2011 at 4:39 PM

16)

```import java.util.*;
class ArraySumAndAverage{
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int num[]=new int[10];
int sum=0;
System.out.println("Enter Array Elements: ");
for(int i=0;i<num.length;i++){
num[i]=input.nextInt();
sum+=num[i];
}
int average=sum/num.length;
System.out.println("Average of elements: "+average);
}
}
```

May 2, 2011 at 4:41 PM

17)

```import java.util.*;
class ArraySort{
public static void main(String[] args) {
Scanner input=new Scanner(System.in);
System.out.println("Enter 5 numbers: ");
Integer array[]=new Integer[5];
for(int i=0;i<array.length;i++){
array[i]=input.nextInt();
}
System.out.println("Sorted Array:");
Arrays.sort(array);
for(int i=0;i<array.length;i++){
System.out.println(array[i]);
}
}
}
```

May 2, 2011 at 4:42 PM

18)

```import java.util.*;

public static void main(String[] args){
Scanner input = new Scanner(System.in);
int[][] A = new int[3][3];
int[][] B = new int[3][3];
int[][] C = new int[3][3];
System.out.println("Enter elements for matrix A : ");
for (int i=0 ; i < A.length ; i++)
for  (int j=0 ; j < A[i].length ; j++){
A[i][j] = input.nextInt();
}
System.out.println("Enter elements for matrix B : ");
for (int i=0 ; i < B.length ; i++)
for  (int j=0 ; j < B[i].length ; j++){
B[i][j] = input.nextInt();
}
System.out.println("Matrix A: ");
for (int i=0 ; i < A.length ; i++){
System.out.println();
for  (int j=0 ; j < A[i].length ; j++){
System.out.print(A[i][j]+" ");
}
}
System.out.println();
System.out.println();
System.out.println("Matrix B: ");
for (int i=0 ; i < B.length ; i++){
System.out.println();
for  (int j=0 ; j < B[i].length ; j++){
System.out.print(B[i][j]+" ");
}
}
System.out.println();
System.out.println();
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
C[i][j]=A[i][j]+B[i][j];
System.out.print(C[i][j]+" ");
}
System.out.println();
}
}
}
```

May 2, 2011 at 4:45 PM

```19)

import java.util.*;
class MatrixMultiplication{

public static void main(String[] args){
Scanner input = new Scanner(System.in);
int[][] A = new int[3][3];
int[][] B = new int[3][3];
int[][] C = new int[3][3];
System.out.println("Enter elements for matrix A : ");
for (int i=0 ; i < A.length ; i++)
for  (int j=0 ; j < A[i].length ; j++){
A[i][j] = input.nextInt();
}
System.out.println("Enter elements for matrix B : ");
for (int i=0 ; i < B.length ; i++)
for  (int j=0 ; j < B[i].length ; j++){
B[i][j] = input.nextInt();
}
System.out.println("Matrix A: ");
for (int i=0 ; i < A.length ; i++){
System.out.println();
for  (int j=0 ; j < A[i].length ; j++){
System.out.print(A[i][j]+" ");
}
}
System.out.println();
System.out.println();
System.out.println("Matrix B: ");
for (int i=0 ; i < B.length ; i++){
System.out.println();
for  (int j=0 ; j < B[i].length ; j++){
System.out.print(B[i][j]+" ");
}
}
System.out.println();
System.out.println();
System.out.println("Result is: ");
System.out.println();

for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
C[i][j]+=A[i][k]*B[k][j];
}
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.print(+C[i][j]+" ");
}
System.out.println();
}
}
}
```

May 2, 2011 at 4:45 PM

19)

```import java.util.*;
class MatrixMultiplication{

public static void main(String[] args){
Scanner input = new Scanner(System.in);
int[][] A = new int[3][3];
int[][] B = new int[3][3];
int[][] C = new int[3][3];
System.out.println("Enter elements for matrix A : ");
for (int i=0 ; i < A.length ; i++)
for  (int j=0 ; j < A[i].length ; j++){
A[i][j] = input.nextInt();
}
System.out.println("Enter elements for matrix B : ");
for (int i=0 ; i < B.length ; i++)
for  (int j=0 ; j < B[i].length ; j++){
B[i][j] = input.nextInt();
}
System.out.println("Matrix A: ");
for (int i=0 ; i < A.length ; i++){
System.out.println();
for  (int j=0 ; j < A[i].length ; j++){
System.out.print(A[i][j]+" ");
}
}
System.out.println();
System.out.println();
System.out.println("Matrix B: ");
for (int i=0 ; i < B.length ; i++){
System.out.println();
for  (int j=0 ; j < B[i].length ; j++){
System.out.print(B[i][j]+" ");
}
}
System.out.println();
System.out.println();
System.out.println("Result is: ");
System.out.println();

for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
for(int k=0;k<3;k++){
C[i][j]+=A[i][k]*B[k][j];
}
}
}
for(int i=0;i<3;i++){
for(int j=0;j<3;j++){
System.out.print(+C[i][j]+" ");
}
System.out.println();
}
}
}
```

May 2, 2011 at 4:48 PM

20)

```import java.util.*;
class  ArrayExample{
public static int getMaxValue(int[] arr){
int maxValue = arr[0];
for(int i=1;i < arr.length;i++){
if(arr[i] > maxValue){
maxValue = arr[i];
}
}
return maxValue;
}

public static int getMinValue(int[] arr){
int minValue = arr[0];
for(int i=1;i<arr.length;i++){
if(arr[i] < minValue){
minValue = arr[i];
}
}
return minValue;
}
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.println("Enter Array Elements: ");
int array[]=new int[5];
for(int i=0;i<array.length;i++){
int num=input.nextInt();
array[i]=num;
}
System.out.println("Smallest No: "+getMinValue(array));
System.out.println("Largest No: "+getMaxValue(array));
}
}
```

May 2, 2011 at 5:08 PM

21)

```import java.util.*;
class Marks
{
public static void main(String[] args)
{
int a=0,b=0,c=0,d=0;
Scanner input=new Scanner(System.in);
for(int i=1;i<=10;i++){
int marks=input.nextInt();
if(marks>80)
a++;
else if(marks>60)
b++;
else if(marks>40)
c++;
else if(marks<=40)
d++;
}
System.out.println("Number of students who have obtained more than 80 marks: "+a);
System.out.println("Number of students who have obtained more than 60 marks and less than equal to 80 marks: "+b);
System.out.println("Number of students who have obtained more than 40 marks and less than equal to 60 marks: "+c);
System.out.println("Number of students who have obtained less than 40 marks: "+d);

}
}
```

May 2, 2011 at 5:41 PM

23)

```import java.util.*;
class FindFromString
{
public static void main(String[] args)
{
int upp=0,low=0,space=0,digit=0,special=0;
Scanner input=new Scanner(System.in);
System.out.print("Enter String: ");
String st=input.nextLine();
char ch[]=st.toCharArray();
for(int i=0;i<ch.length;i++){
if(Character.isUpperCase(ch[i])){
upp++;
}
else if(Character.isLowerCase(ch[i])){
low++;
}
else if(Character.isWhitespace(ch[i])){
space++;
}
else if(Character.isDigit(ch[i])){
digit++;
}
else{
special++;
}
}
System.out.println("No of uppercase characters: "+upp);
System.out.println("No of lowercase characters: "+low);
System.out.println("No of space characters: "+space);
System.out.println("No of digit characters: "+digit);
System.out.println("No of special characters: "+special);
}
}
```

May 2, 2011 at 5:42 PM

24)

```import java.util.*;
public class CheckPalindrome{
public static void main(String[]args){
Scanner input=new Scanner(System.in);
System.out.print("Enter String: ");
String st=input.next();
String str[]=st.split("");
String reversedSt="";
for(int i=str.length-1;i>=0;i--){
reversedSt+=str[i];
}
if(st.equalsIgnoreCase(reversedSt)){
System.out.println("String is palindrome");
}
else{
System.out.println("String is not palindrome");
}
}
}
```

May 2, 2011 at 5:51 PM

25)

```import java.util.*;
import java.util.regex.*;
class  CheckEmailId{
public static boolean isEmailValid(String email){
boolean isValid = false;
String expression = "^[\\w\\.-][email protected]([\\w\\-]+\\.)+[A-Z]{2,4}\$";
CharSequence inputStr = email;
Pattern pattern = Pattern.compile(expression, Pattern.CASE_INSENSITIVE);
Matcher matcher = pattern.matcher(inputStr);
if(matcher.matches()){
isValid = true;
}
return isValid;
}
public static void main(String[] args){
Scanner input=new Scanner(System.in);
System.out.print("Enter Email ID: ");
String email=input.nextLine();
if(isEmailValid(email)){
System.out.println("Valid!");
}
else{
System.out.println("Invalid Email-id!");
}
}
}
```

May 2, 2011 at 5:56 PM

26)

```import java.util.*;
class SortList
{
public static void main(String[] args)
{   Scanner input=new Scanner(System.in);
ArrayList<String> list=new ArrayList<String>();
System.out.println("Enter names of 5 Cricketers: ");
for(int i=0;i<5;i++){
String name=input.nextLine();
}
System.out.println("Names of 5 Cricketers in sorted order: ");
Collections.sort(list);
for(int i=0;i<list.size();i++){
System.out.println(list.get(i).toString());
}
}
}
```

May 2, 2011 at 5:58 PM

27)

```import java.util.*;
import java.io.*;

public class FirstLetter{
public static String capitalizeFirstLetter( String str ) {
final StringTokenizer st = new StringTokenizer( str, " ", true );
final StringBuilder sb = new StringBuilder();

while ( st.hasMoreTokens() ) {
String token = st.nextToken();
Character ch=Character.valueOf(token.charAt(0));
token = String.format( "%s%s",Character.toUpperCase(token.charAt(0)),token.substring(1) );
sb.append( token );
}
return sb.toString();
}
public static void main(String[]args) throws Exception{
System.out.print("Enter the sentence : ");
FirstLetter letter=new FirstLetter();
String words=letter.capitalizeFirstLetter(inputString);
System.out.println(words);
}
}
```

May 2, 2011 at 6:00 PM

28)

```import java.util.*;
public class ReverseString{
public static String reverse(String st){
String rev = new StringBuffer(st).reverse().toString();
return rev;
}
public static void main(String[]args){
Scanner input=new Scanner(System.in);
System.out.println("Enter string: ");
String str=input.nextLine();
System.out.println("Reverse: " + reverse(str));
}
}
```

May 3, 2011 at 4:19 PM

30)

```import java.util.*;
class CountFrequency
{
public static void main(String[] args)
{
int count=0;
Scanner input=new Scanner(System.in);
System.out.println("Enter string: ");
String str=input.nextLine();
System.out.println("Enter letter to count its frequency: ");
char chr=input.next().charAt(0);
char ch[]=str.toCharArray();
for(int i=0;i<ch.length;i++){
if(ch[i]==chr){
count++;
}
}
System.out.println("Frequency of "+chr+": "+count);
}
}
```

May 3, 2011 at 4:19 PM

31)

```import java.util.*;
class StringElementNo
{
public static void main(String[] args)
{
int count=0;
Scanner input=new Scanner(System.in);
System.out.println("Enter string: ");
String str=input.nextLine();
char ch[]=str.toCharArray();
for(int i=0;i<ch.length;i++){
System.out.println("character "+ch[i]+" is at position: "+i);
}

}
}
```

May 3, 2011 at 4:25 PM

32)

```import java.util.*;
{
public static void main(String[] args)
{
try{
float c=0;
Scanner input=new Scanner(System.in);
System.out.print("Enter number 1: ");
int a=input.nextInt();

System.out.print("Enter number 2: ");
int b=input.nextInt();

c=a+b;
System.out.println(c);
}
catch(Exception e){
System.out.println(e);
}
}
}
```

May 3, 2011 at 4:31 PM

33)

```import java.util.*;
class  ArrayExample
{
public static void main(String[] args)
{
try{
Scanner input=new Scanner(System.in);
System.out.print("How many numbers you want to ass in your array: ");
int size=input.nextInt();
int array[]=new int[size];
System.out.println();
System.out.println("Enter Array Elements: ");
for(int i=0;i<array.length;i++){
array[i]=input.nextInt();
}
for(int i=0;i<array.length;i++){
System.out.println(array[i]);
}
}
catch(Exception e){
System.out.println(e);
}
}
}
```

May 3, 2011 at 4:41 PM

34)

```class ReadChar
{
public static void main(String[] args) throws Exception
{
System.out.print("Enter character: ");
char ch=(char)i;
System.out.println();
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u'){
throw new Exception("Vowel Exception");
}
else if(ch=='X'||ch=='x'){
throw new Exception("Exit Exception");
}
else{
for(int j=1;j<=5;j++){
System.out.println(ch);
}
}
}
}
```

May 3, 2011 at 4:45 PM

35)

```import java.util.*;
class NoMatchingException
{
public static void main(String[] args) throws Exception
{
Scanner input=new Scanner(System.in);
System.out.print("Enter string: ");
String st=input.nextLine();
if(!st.equals("India")){
throw new Exception("Not Matching Exception");
}
}
}
```

May 3, 2011 at 5:09 PM

36)

```abstract class Shape{
double PI=3.14;
abstract public double area();
abstract public double perimeter();
}
class Rectangle extends Shape{
int l, b;
Rectangle(int l,int b){
this.l=l;
this.b=b;
}
public double area(){
return l*b;
}
public double perimeter(){
return (2*l)+(2*b);
}
}
class Circle extends Shape{
int r;
Circle(int r){
this.r=r;
}
public double area(){
return PI*r*r;
}
public double perimeter(){
return 2*PI*r;
}
}
public class AbstractClassExample{
public static void main(String args[]) {
Rectangle rect=new Rectangle(2,5);
System.out.println("Area of Rectangle: "+(rect.area()));
System.out.println("Perimeter of Rectangle: "+(rect.perimeter()));

Circle cir=new Circle(5);
System.out.println("Area of Circle: "+(cir.area()));
System.out.println("Perimeter of Circle: "+(cir.perimeter()));

}
}
```

May 3, 2011 at 5:11 PM

37)

Example of Vector

38)

```import java.util.*;
class  Factorial{
public static int findFactorial(int n)
{
if (n == 1) {
return n;
}
else {
return n * findFactorial(n - 1);
}
}
public static void main(String[] args)
{
Scanner input=new Scanner(System.in);
System.out.print("Enter number: ");
int num=input.nextInt();
System.out.println("The factorial of " +num+"  is : " + findFactorial(num));
}
}
```

QUE 50 ...please show output also...
QUE 50 ...please show output also...  Q1. Write a program to find... a program that asks the user for the amount to be deposited and also the amount...) Q45. Write an applet to draw Joker face.  please early as possible
Show output as a xml file using Velocity
Show output as a xml file using Velocity       This Example shows you how to show output as a xml file...;to produce the output.#foreach( \$stu in \$stuList ): This works same
JSP Que.
JSP Que.  How to pass string one jsp to another jsp without using input tag
i want java code for this xml file...please show me..
i want java code for this xml file...please show me..   xbrli:shares xbrli:pure iso4217:INR
que - Struts
que  how can i run a simple strut programm? please explain with a proper example. reply soon.  Hi Friend, Please visit the following link: http://www.roseindia.net/struts/ Thanks
Interview Que
Interview Que  I want to Java Interview Questions   Please visit the following link: Java Interview Questions
que 2 - Java Beginners
que 2  WAP to input a string & print out the text withthe uppercase & lowercase letters reversed,but all other characters should remain the same. eg: input:WelComE TO School output:wELcOMe to sCHOOL  Hi Friend
que 1 - Java Beginners
que 1  WAP to enter a sentence & count the no. of times a particular word occurs in it.Display the frequency of the searched word. eg- input:the quick brown fox jumps over the lazy dog. word to be searched:the output
output
output  Sir,I am experiencing some problems with the output of this program.I got some useful help this website,but the output of the program isn't producing what it should.let me explain the output below is what happen when
Show content of .vm file as output using Velocity
Show content of .vm file as output using Velocity  ......" in StringOutput.vm file, that message will be show as output.    ... content of .vm file using velocity and also shows how to use Iterator
how to output text from comboBox from first frame to textField on the second frame? please help me.. thank you in advance..  how to output text from comboBox from first frame to textField on the second frame? please help me
Output of flex
Output of flex  hi....... please provide the name of the output file. What is the output of flex applications? please rply ASAP........ Thanks
triangle output
triangle output  program to get the following output: * *   Hi Friend, Please specify the pattern properly. Thanks
What is the output if....
");   When we put 50 as a lower limit value, output comes: Entering...What is the output if....  Here is my code. what is the output if a. the value of lowerLimit is 50? b. if the value of lowerLimit is 150? int
I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way.....
how 2 start this...please show me my way.....  I want Mini Java Project for Student Admission System. actually i want 2 know how 2 start this...please show me my way
input output
It uses for writing data to a file and also implements an output.... This class also connected into a piped output stream... Input And Output
what will the output
what will the output  class Parent has a public method play() that prints "Parent is playing". A class Child that extends the Parent class also has... = (Parent) sonu; p.play(); What will be the output of above section of code
to show graph
to show graph  by clicking on submit button how to show the graph by fetching data in mysql?   Please visit the following link: JSP graph by fetching data in mysql
triangle output
triangle output  program to get the following output
output variable
output variable  if i want to print output of three variables when i wrote the code e.g SYStem.out.PRINTln(answer + answer1 + answer 2) only output of answer is getting printed out? can you help
Discounted Website, 50% Discount on website,Website Rs. 5000/- a year!
professionally designed website for your business at 50% discounted rate... all these only for Rs. 5000/- (at 50% discounted rate).  This offer is valid only till 31st December. You will also get: 5 pages websites free
in the file. Also it should be displayed on the screen. However my code doesn't display the anagram on screen or the output file! Please show me whats wrong. Thanks i...I need help on my Java code.... please please help me out!?  Well my
What will be the Output?
What will be the Output?  int[] number = {5,3,6,10,1} int temp; for (int i=0; inumbers[j]) { temp=numbers[i]; numbers[i]=numbers[j] number[j]=temp
output of the program
output of the program  public static int sum(List list) { int sum = 0; for ( Iterator iter = list.iterator(); iter.hasNext(); ) { int i = ((Integer)iter.next()).intValue(); sum += i; } return sum
xml output
xml output  generate an xml output in the following format <FileCount> <DOC>AA <RTF>BB <PDF>CC <Total>DD where AA=total number of .DOC files found BB=total number of .RTF files found,etc
output error
output error  this is my program import java.io.*; public class separate { public static void main(String[] args)throws IOException...]; for (k=0;k } } if i enter "my name" as the input the output
Main memory is also known as
Main memory is also known as   Main memory of a computer is also known
what is the output?
what is the output?  public class MyAr{ public static void main(String argv[]) { int[] i=new int[5]; System.out.println(i[5]); } }   It gives ArrayIndexOutOfBoundsException as you haven't add element to array. Correct