Skip to content

557029/JavaCodeAssessment

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JavaCodeAssessment

Java Code Assessment

Tasks:

  1. Write class that implements below interface. Write a function (using Java syntax) that prints out the numbers 1 to 500 with the following constraints:
    1. For multiples of six print "Fizz" instead of the number.
    2. For multiples of ten print "Buzz".
    3. For numbers which are multiples of both six and ten print "FizzBuzz".
public interface IFizzBuzz {
  public void doFizzBuzz();
}
  1. Write an implementation of the Reverser interface which takes two strings and returns true if and only if the first string is the reverse of the second string. Multiple different implementations are encouraged.
    • Example: isReverse("abc", "cba") returns true
    • Example: isReverse("abc", "xyz") returns false
public interface Reverser 
{
	public boolean isReverse(String string1, String string2);
}
  1. Write a "Square" class that implements the below Shape interface. Multiple different implementations are encouraged.
public interface Shape 
{
	public int perimeter();
	public int area();
}
  1. Write an implementation of the Fibonacci interface which computes the Nth Fibonacci number. Multiple different implementations are encouraged. getFibonacci(n) = sum of last two Fibonacci numbers.
    • getFibonacci(0) = 0
    • getFibonacci(1) = 1
    • getFibonacci(2) = 1
    • getFibonacci(3) = 2
    • getFibonacci(4) = 3
public interface Fibonacci 
{
	public int getFibonacci(int n);
}
  1. Write a program to print all prime numbers from 1 to 100. A prime number is a number which is greater than 1 and only divisible by 1 or itself. Please use the interface below to determine if a number is prime for your program.

Examples:

  • isPrime(5) returns true.
  • isPrime(6) returns false.

Interface:

public abstract interface PrimeNumber
{
public boolean isPrime(int number);  
}

About

Java Code Assessment

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages