[Go to site: main page, start]

0% found this document useful (0 votes)
6 views11 pages

Java Programming Exercises and Solutions

The document contains a series of programming tasks in Java, each requiring the creation of specific programs to perform various functions such as displaying messages, calculating percentages, checking voting eligibility, and handling exceptions. Each task is followed by a placeholder for the program code and the expected output. The tasks cover fundamental programming concepts including loops, methods, classes, and exception handling.

Uploaded by

gitashree nayak
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views11 pages

Java Programming Exercises and Solutions

The document contains a series of programming tasks in Java, each requiring the creation of specific programs to perform various functions such as displaying messages, calculating percentages, checking voting eligibility, and handling exceptions. Each task is followed by a placeholder for the program code and the expected output. The tasks cover fundamental programming concepts including loops, methods, classes, and exception handling.

Uploaded by

gitashree nayak
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

1.

Write a program in Java to instruct the computer to


display a welcome message in Java output window.

Program:

Output:

2. Write a program in Java to calculate percentage of


two students.
Program:

Output:
3. Write a program in Java to cheque eligibility of a
person to vote on the basis of universal adult
franchise.
Program:

Output:

4. Write a program in Java to display name of the day


of the week according to the given number.
Program:
Output:

5. Write a program in Java to print the squares of


numbers from 1 to 10.
Program:
Output:

6. Write a program in Java with the method that given


the length and breadth of the rectangle as parameters
return the area of rectangle.
Program:
Output:

7. Write a program in Java that uses void as return


type.
Program:

Output:
8. Write a program in Java to create a class with data
members and method members.
Program:

9. Write a program in Java to create a constructor of a


class.
Program:
10. Write a program in Java to create an object of a
class using new keyword and access its data member
and method members.
Program:

Output:
11. Write a Java program to Generate Multiplication
Table (number of iteration (from 1 to 10)) using for
loop of a number by getting the input of a number of
user choice during runtime.
Program:

Output:

12. Write a program in Java to handle division by zero


exception.
Program:
Output:

13. Write a JAVA program to print the sum of first 10


natural numbers 1 to 10..
Program:

Output:
14. Write a Java program to print the FACTORIAL of
a given number by getting the input of a number of
user choice during run time.
Program:

Output:

15. Write a program in Java to create two threads


by implementing the runnable interface.
Program:
Output:

You might also like