Java

Java Practice Exercise

Programmingempire

This Java Practice Exercise contains programming problems on core Java.

Further Reading

30+ Basic Java Programs

Java Code Examples

The following Java Practice Exercise will help you learn the Java Programming Language.

  1. Create a Java application that computes and displays the area of a circle.
  2. Demonstrate how typecasting & conversions take place in Java.
  3. Write code in Java language to perform add, subtract, divide and multiply 2 numbers.
  4. Create a Java application to display the grade of a student.
  5. Demonstrate using a Java program to accept numbers as Command line arguments.
  6. Create a Java application that randomly generates a number and checks whether it is prime or not.
  7. Develop an application in Java that randomly generates a number from a range of [1=100000] and checks whether it is Armstrong or not.
  8. Write code to initialise and print the elements of an array of integers by taking command line arguments.
  9. Perform sorting on an array in ascending and descending order using a Java program.
  10. Create a Java program to display the smallest element of an array of 5 integers.
  11. Write a program to display the difference between smallest and largest elements of an array of 5 integers.
  12. Create a Java application to demonstrate the working of any Ten String class functions.Write code to extract surname from the complete name
  13. Write a program to create a class called StringDemo and declare three strings and use functions like length, charAt, and equals on them.
  14. Develop a program to create a class called Box and calculate its volume by calling its method.
  15. Build a Java application to create a class called Test and pass its object to one of its methods to illustrate the usage of reference variables.
  16. Write a program to create a class called UseStatic and declare some static variables, a static method that will print those variables, and a static block that will perform some operation on that variable.
  17. Develop a Java application to create a class Add that will add two numbers by using a default constructor. Write code to create a class called triangle with base and height as the attributes and calculate its area using the parameterized constructor.
  18. Develop an application in Java to create a class called Rectangle and calculate its area using this keyword.
  19. Write a program to create a class Area and calculate the area of the rectangle and circle using method overloading.
  20. Demonstrate abstract classes in Java.
  21. Demonstrate how to create a class called Box with instance variables width, height, and depth. Create another class BoxWeight which inherits class Box with an additional instance variable weight. Compute the volume of the box using inheritance.
  22. Create a class Figure and its 2 subclasses Rectangle and Triangle and calculate its area using dynamic method dispatch.
  23. Implement the above program using abstract classes by making the Figure class abstract.
  24. Create an application to show the usage of the final keyword with class, variables, and methods in java.
  25. Write relevant programs showing the usage of package and access protection in java.
  26. Create a java program to show the concept of importing a package.
  27. Write code in Java to implement stacks using interfaces.
  28. Demonstrate in Java the implementation of nesting of the interface.
  29. Write relevant programs to show the usage of try, catch, throw, throws, and finally in java.
  30. Develop an application in Java to create a user-defined exception class using the extends keyword.
  31. Create an application that demonstrates how a program throws exceptions if the age of the voter is less than 18.
  32. Similarly, create another application that throws exceptions if the stack is full or is empty.
  33. Write a program that throws exceptions if the bank balance drops below 1000 due to any transaction.
  34. Create an application to show the concept of creating Thread through thread class and Runnable interface
  35. Write Java code to print multiples of 2,3,4 simultaneously.
  36. Demonstrate through a program that high priority thread gets more CPU attention than a low-priority thread.
  37. Write relevant programs to show the concept of thread synchronization and inter-thread communication.
  38. Create an application in Java that accepts a hostname and displays its IP address.
  39. Write a TCP/IP client-server program that echoes whatever is typed on the client to the server.
  40. Develop a Java application to demonstrate client-server application using Java RMI.
  41. Write a program that displays the life cycle of the Applet and other relevant programs that shows the implementation of Applets in java.
  42. Create a Java application to draw different figures using AWT.
  43. Develop a Java application to add a label, Buttons, Textfield, lists, etc using AWT.
  44. Create a login window to check user name and password using text fields and command buttons.
  45. Develop an application in Java that creates 3 control boxes for font name, size, and style, change the font of the text according to user selection.
  46. Create a Java program layout Manager to add different controls on a frame.
  47. Demonstrate using a Java program different event handlers.
  48. Develop a Java application that shows working with Graphics, colors, and fonts in AWT.
  49. Write a program to implement the Swing 2 function calculator.
  50. Create a Swing login window to check user name and password using text fields and command buttons.
  51. Demonstrate how to create a table in a database via java.
  52. Create an application in Java that updates some records.
  53. Write a program to create a simple bean.
  54. Create a program in java to show the connectivity of java with the database using SQL statements.
  55. Develop an application in Java to insert a record in the database.

Further Reading

Spring Framework Practice Problems and Their Solutions

From Google to the World: The Story of Go Programming Language

Why Go? Understanding the Advantages of this Emerging Language

Creating and Executing Simple Programs in Go

20+ Interview Questions on Go Programming Language

Java Practice Exercise

programmingempire

Princites

You may also like...