The document lists 25 Java programming problems ranging from basic programs like checking if a number is even or odd to more complex programs involving classes and objects like calculating area using different classes. Many involve writing classes to model real-world entities like students, rectangles, triangles, and employees and include methods to perform operations on their attributes.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
73 views
Java QB
The document lists 25 Java programming problems ranging from basic programs like checking if a number is even or odd to more complex programs involving classes and objects like calculating area using different classes. Many involve writing classes to model real-world entities like students, rectangles, triangles, and employees and include methods to perform operations on their attributes.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2
1.
Write a java program to check if a number is even or odd
2. Write a java program to add two numbers 3. Write a program to check if the year is a leap year 4. Write a program to find the quotient and remainder 5. Write a Java Program to reverse a string without using String inbuilt function 6. Write a Java Program to swap two numbers without using the third variable 7. Write a Java Program to find whether a number is prime or not 8. Write a Java program to display first n prime numbers 9. Write a Java Program to find whether a string or number is palindrome or not 10. Write a Java Program for Fibonacci series 11. Write a Java program to find the factorial of a number 12. Write a Java program to find the GCD of a number 13. Write a Java program to calculate the area of a rectangle and a square and a triangle 14. Write a Java program to count the number of characters in a string 15. Write a Java program to find the duplicate characters in a string 16. Write a Java program to sort a string in alphabetical order 17. Write a Java program to reverse the contents of an array 18. Write a program to remove all white spaces from a string 19. Create a class named 'Student' with String variable 'name' and integer variable 'roll_no'. Assign the value of roll_no as '2' and that of name as "John" by creating an object of the class Student Assign and print the roll number, phone number and address of two students having names "Sam" and "John" respectively by creating two objects of class 'Student 20. Write a program to print the area and perimeter of a triangle having sides of 3, 4 and 5 units by creating a class named 'Triangle' without any parameter in its constructor 21. Write a program to print the area of two rectangles having sides (4,5) and (5,8) respectively by creating a class named 'Rectangle' with a method named 'Area' which returns the area and length and breadth passed as parameters to its constructor 22. Write a program to print the area of a rectangle by creating a class named 'Area' having two methods. First method named as 'setDim' takes length and breadth of rectangle as parameters and the second method named as 'getArea' returns the area of the rectangle. Length and breadth of rectangle are entered through keyboard 23. Write a program to print the area of a rectangle by creating a class named 'Area' taking the values of its length and breadth as parameters of its constructor and having a method named 'returnArea' which returns the area of the rectangle. Length and breadth of rectangle are entered through keyboard 24. Write a program by creating an 'Employee' class having the following methods and print the final salary. 1 - 'getInfo()' which takes the salary, number of hours of work per day of employee as parameter 2 - 'AddSal()' which adds $10 to salary of the employee if it is less than $500. 3 - 'AddWork()' which adds $5 to salary of employee if the number of hours of work per day is more than 6 hours 25. Write a program to print the first non-repeated character of String