You are on page 1of 3

Java Questions for practice

CSC 201
Question - 1
Write a static method named ‘midpoint’ that accepts three integers as
parameters and return true if one of the integers is the midpoint
between the other two integers. It should return false if no such
midpoint relationship exists.

Example:
Calls such as the following return true:
Midpoint(4 , 6, 8)
Midpoint(2, 10, 6)
Midpoint(8, 8, 8)
Calls such as following return false:
Midpoint( 3, 1, 3)
Midpoint(1, 3, 1)
Midpoint(21, 9, 58)
Question - 2
• Try the number of occurrences of a word
using “StringTokenizer”, “Scanner class –
hasNext() method”, “indexOf() method”.
Any other way would score you an extra
credit point!

You might also like