Archive for the 'Quiz' Category

Quiz

Coders4fun Quiz #4

Main.java

public class Main {

  public static void main(String[] args) {
    System.out.print(Quiz.GetMagicNumber());
  }

}

Quiz.java

public class Quiz {

  static int magicNumber = 3;

  public static int GetMagicNumber()
  {
    return magicNumber;
  }
}

What we need to add in Quiz class to print 5 instead of 3?

Quiz

Coders4fun Quiz #3: Will it compile?

Will this code compile??? Why?

foo.h

class Foo
{
	public:
		Foo();

		void fooo();
	private:
		int i;
		char c;
		short s;
	protected:
		char b;
		char e;

		char getFoo();
}

foo.cpp

#include "foo.h"

Foo::Foo()
{
	for (int i = 0; ; ) { }
}

void Foo::fooo()
{
while(true)
{
	c = 'f';
}
}

char getFoo()
{;
	return c + 2;
}

Quiz

Coders4fun Quiz #2

This quiz is not original and isn’t about programming but I think it’s funny, so I publish it! :D
There is a pullman with 7 girls.
Every girl has 7 rucksack.
In each rucksack there are 7 big cats.
Every big cat has 7 small cats.
Every cat has 4 legs.

How much legs there are in the pullman?

C, Quiz

Coders4fun Quiz #1

What will be printed using this c++ code?

#include <iostream>

int main()
{
	int i = 0;
	for (i = i == 0; i < 9; i = 1 + i * 2);
		std::cout<<i<<std::endl;
	return 0;
}

Please don’t cheat using a compiler! :)

P.S.
Of course the example compiles!