Interview’s Logic Tests

Yes Guys !

I will write a post about this, because recently I made some logic tests that are VERY VERY easy, but because of my nervous I made some mistakes :/ Really, I have to stop to stay anxious about something… So, let’s go:

Tests Fibonnaci – JAVA:

package Tests;
public class Main {
    static long fibo(int n) {
       if (n < 2) {
          return n;
else {
          return fibo(n – 1) + fibo(n – 2);
}
}
public static void main(String[] args) { // test
        for (int i = 0; i < 15; i++) {
System.out.print(Main.fibo(i) + “\t”);
}
}
}

Tests Reverse String – JAVA:

package Tests;


public class Main {

    static String converse() {
        String a = "This is a string...";
        String b = "";

        for (int i = a.length() - 1; i >= 0; i--) {
            b = b + a.charAt(i);
        }
        return b;
    }

    public static void main(String[] args) { // test 
      System.out.println(Main.converse());

    }
}

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 )

Facebook photo

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

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.