Top 10 Java Interview Programming Questions with Solutions

screen-shot-2016-10-05-at-11-18-07-pm

Wonder how to prepare for the interview programming questions?Here is a great way to get started. These ten questions will warm you up to get started with a successful interview.

Without much further ado, here are the questions:

1. Write a method that uses a for loop to display numbers in descending order in the step of 5 starting from 100. Call your method from the main method.

e.g., The output should be:

100

95

90

5

0
2. Write a method that uses a while loop. This method would replace every vowel in the String with X. Call your method from the main method.

e.g., the String
Java is Fun
should become
JXvX Xs FXn
3. Write a method that uses a do while loop. This method would reverse a String. Call your method from the main method.

e.g., the String
Java
should become
avaJ

4. Write a method that checks if a String is a Palindrome. Call your method from the main method.

5. Write a method that prints the multiplication table of the user provided number. Call your method from the main method.

e.g., If the user enters the value of 9
should become, the program prints
9
18
27
36


81
90

6. Write a method that checks if a number is a Prime number. Call your method from the main method.

7. Write a method that accepts two numbers are returns the maximum of Two. Call your method from the main method.

8. Create a method that accepts two numbers and returns the minimum of Two. Call your method from the main method.

9. Write a method that accepts two numbers and returns the average of Two. Call your method from the main method.
10. Write a method that calls all the above methods. Log the time at the begining of this method and at the end. Print how many milliseconds elapsed in executing all the above methods Call your method from the main method.

Solution:

Solution is located at our tutorial website http://sansatechnology.com/tutorials/java/ten-interview-loop-questions.php

 

Have questions? Contact us:
Email: contact@sansatechnology.com
Web: http://www.sansatechnology.com

Need a boost for your professional career? Try our professional training courses: http://www.sansatechnology.com/training
We are hiring! Check out our current job openings at: http://www.sansatechnology.com/career.php

Advertisements

About sansatechnology

Sansa Technology is an IT staffing, Consulting and Training company located in the heart of Silicon Valley. If you are a consultant looking for your new gig, send us your resume to us. If you are looking for training in the field of White Box Testing, Java, Java EE, Selenium, DevOps, Android and others, connect with us as well. Visit us at www.sansatechnology.com or email contact@sansatechnology.com
This entry was posted in Uncategorized and tagged , . Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s