0% found this document useful (0 votes)
3 views

Java Lab Manual 1

The document contains a series of Java programming assignments focused on various concepts such as type conversion, arithmetic operations, control structures, loops, and object-oriented programming. Each assignment requires the implementation of specific functionalities, including user input handling, conditional statements, and class definitions. The tasks range from basic operations to more complex programming challenges, aimed at enhancing Java programming skills.

Uploaded by

Mukesh Surela
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views

Java Lab Manual 1

The document contains a series of Java programming assignments focused on various concepts such as type conversion, arithmetic operations, control structures, loops, and object-oriented programming. Each assignment requires the implementation of specific functionalities, including user input handling, conditional statements, and class definitions. The tasks range from basic operations to more complex programming challenges, aimed at enhancing Java programming skills.

Uploaded by

Mukesh Surela
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

SRI BALAJI P.

G MAHAVIDYALAYA
Java Technology
Assignments-1

Q1. Write a Java program to demonstrate automatic type conversion from int to float and double.

Q2. Write a program to demonstrate explicit type casting from double to int and observe the data loss.

Q3. Write a program to accept two numbers from the user and perform all arithmetic operations (+, -, *, /, %).

Q4. Write a program that takes three numbers from the user and determines which one is the greatest using
relational and logical operators.

Q5. Write a Java program that demonstrates both pre-increment and post-increment behavior.

Q6. Write a Java program that checks if a number entered by the user is even or odd using the if-else
statement.

Q7. Write a Java program that accepts the age of a person and checks whether the person is eligible to vote
(age >= 18). Use nested if statements to check if the person is a minor or an adult.

Q8. Write a Java program that accepts a number between 1 and 7 and prints the corresponding day of the
week using the switch statement.

Q9. Write a Java program that accepts marks from the user and assigns a grade based on the following
criteria:
Marks >= 90: A
Marks >= 80 and < 90: B
Marks >= 70 and < 80: C
Marks >= 60 and < 70: D
Marks < 60: F
Q10. Write a program that accepts a year from the user and checks whether it is a leap year using the
conditional (?:) operator.
Q11. Write a Java program that accepts two numbers and an operator (+, -, *, /) from the user and performs
the corresponding operation using the switch statement.

Q12. Write a Java program to find the sum of the first n natural numbers using a for loop.

Q13. Write a Java program to calculate the factorial of a number using a while loop.

Q14. Write a Java program that takes an integer input from the user and checks whether the number is prime
using a for loop.

Q15. Write a Java program that prints the Fibonacci series up to n terms using a while loop.

Q16. Write a program to reverse the digits of a number using a while loop.
Q17. Write a Java program to print the multiplication table of a given number using a for loop.

Q18. Write a Java program using nested loops to print the following pattern:
1
12
123
1234
Q19. Write a Java program that takes an integer input and calculates the sum of its digits using a do-while
loop.

Q20. Write a Java program to check if a number is a palindrome or not using a while loop.

Q21. Write a Java program to count the number of vowels in a given string using a for loop.

Q22. Write a Java program that prints the numbers from 1 to 10. Use a break statement to stop the loop when
the number is equal to 7.

Q23. Write a Java program that prints numbers from 1 to 10, but uses the continue statement to skip printing
the number 4.

Q24. Write a Java program that uses a switch statement to display the name of a month based on its number
(1 for January, 2 for February, etc.). Use break to terminate each case.

Q25. Write a Java program that defines a method to find the maximum of two numbers using the return

Q26. Write a Java program that uses both break and continue in the same loop to print numbers from 1 to 10
but stops the loop if the number is 8 and skips the number 5.

Q27. Create a Java class Student with attributes name, rollNumber, and marks. Add methods to input and
display the student’s details. Create objects of the Student class and display the details of multiple students.

Q28. Write a Java program that defines a class Rectangle with attributes length and breadth. Implement two
constructors: one default constructor and one parameterized constructor. Use the constructors to initialize
the rectangle’s dimensions and calculate its area.

Q29. Write a Java class Employee that has the attributes name, salary, and department. Include a method to
display the employee’s details and another method to calculate an annual bonus based on the employee’s
salary.

Q30. Write a Java program that defines a class Car with attributes brand, model, and price. Use private access
for price, public for brand, and protected for model.

You might also like