25 Java practice programs focusing on: Static methods Non-static (instance) methods Parameterized methods Non-parameterized methods

25 Java practice programs focusing on:

  • Static methods

  • Non-static (instance) methods

  • Parameterized methods

  • Non-parameterized methods

These are great for SDET logic building and Java interview prep.


๐Ÿ”น Static Method Practice (6 programs)

  1. Create a static method to print "Hello, World!"

  2. Static method to add two numbers and return the sum.

  3. Static method to check if a number is even or odd.

  4. Static method to convert Celsius to Fahrenheit.

  5. Static method to find the maximum of three numbers.

  6. Static method to validate if an email string contains '@' and '.'.


๐Ÿ”น Non-Static (Instance) Method Practice (6 programs)

  1. Instance method to print the full name from first and last name fields.

  2. Instance method to calculate area of a rectangle (length × breadth).

  3. Instance method to count vowels in a string.

  4. Instance method to check if a given year is a leap year.

  5. Instance method to display whether the object’s age field is eligible to vote.

  6. Instance method to reverse a given string.


๐Ÿ”น Parameterized Method Practice (6 programs)

  1. Method to check if a given number is prime (pass number as parameter).

  2. Method to calculate factorial of a number using parameter.

  3. Method to check if a given string is a palindrome (string parameter).

  4. Method to return grade based on marks passed as parameter.

  5. Method to validate phone number length (parameter: String phone).

  6. Method to check login validity (parameters: username, password).


๐Ÿ”น Non-Parameterized Method Practice (7 programs)

  1. Method to print the multiplication table of 5 (fixed inside method).

  2. Method to display the current system date and time.

  3. Method to print all even numbers from 1 to 50.

  4. Method to display "Welcome, User!" message.

  5. Method to generate and print a random number.

  6. Method to print ASCII values of A-Z.

  7. Method to list all prime numbers from 1 to 100.


๐Ÿ’ก Tip for SDET: These methods can later be wrapped into test cases or utility classes for test frameworks (like using them in Selenium tests, API test validators, etc.).

Would you also want me to next give you 25 constructor-based practice problems? (Useful for object creation, OOP concepts — often asked in SDET coding rounds.)

Comments

Popular posts from this blog

10 automation test cases for https://www.saucedemo.com/ (Sauce Demo)

Java Roadmap for SDET Superstars!

Mastering XPath in Selenium 4 ๐Ÿš€ – Supported Functions & Axes Explained