Help with a java question...
If this is against the rules here, please remove this topic.
I'm trying to join a new forum specifically for java games, but to activate your account you need to answer a small trivia quiz. Being the java noob I am, I'm unable to complete the trivia to activate my account. I can't find a way to email/message an admin on the site, so my idea was to ask the java masters here for the answers, if this is in the wrong topic/not allowed, please delete it as I don't want to break the rules here.
Code :
int o = 2;
int j = "JZG".hashCode() % 3000;
int w = "DUY".hashCode() % 3000;
for (int i = 0; i <= w; i++)
o = (o ^ i) % j;
return o;
What is the returned value?
What is the greatest common divisor of the previous two results?
Re: Help with a java question...
Erm, forgive my ignorance but... Why can't you just execute the code to find out?
Re: Help with a java question...
I couldn't seem to get it to execute:/I'll try again..
Re: Help with a java question...
If you're thinking of making games in Java, the logical step is to learn Java first.
Because of that, we can give you assistance to get that code working.
You go off and try and execute the code now and come back when you get stuck, posting any relevant error messages and issues at the same time.
Best of luck.
Re: Help with a java question...
I can't execute the code...I can get it to run, but I can't get it to print o?
Re: Help with a java question...
So you can't execute it? but you can run it? No comprende.
Print the code that you're working with.
Re: Help with a java question...
it runs, but how would i get it to show me the value of 'o'? I've tried System.out.println(o); but it hasn't worked.
Code :
public class test{
public static void main(String[] args) {
}
public static code(){
int o = 2;
int j = "JZG".hashCode() % 3000;
int w = "DUY".hashCode() % 3000;
for (int i = 0; i <= w; i++)
o = (o ^ i) % j;
return 0;
}
}
Re: Help with a java question...
For anything to be executed in Java there needs to be an entry point inside the method: public static void main(String[] args){}.
Easiest way to deal with this is for you to take all the code from inside the method "code" and place it inside the braces of the "main" method.
Print out o using System.out.println("Result: " + o);
Just to ease your process however, the answer to all questions on the gaming site are 1955 :)
Re: Help with a java question...
Quote:
Originally Posted by
newbie
For anything to be executed in Java there needs to be an entry point inside the method: public static void main(String[] args){}.
Easiest way to deal with this is for you to take all the code from inside the method "code" and place it inside the braces of the "main" method.
Print out o using System.out.println("Result: " + o);
Just to ease your process however, the answer to all questions on the gaming site are 1955 :)
Okay, thankyou! and thankyou very much!