Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Help with a java question...

  1. #1
    Junior Member
    Join Date
    Sep 2012
    Posts
    15
    My Mood
    Stressed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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.
     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?
    Last edited by Huw; September 20th, 2012 at 12:51 PM.


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: Help with a java question...

    Erm, forgive my ignorance but... Why can't you just execute the code to find out?
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. #3
    Junior Member
    Join Date
    Sep 2012
    Posts
    15
    My Mood
    Stressed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Help with a java question...

    I couldn't seem to get it to execute:/I'll try again..

  4. #4
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default 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.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  5. #5
    Junior Member
    Join Date
    Sep 2012
    Posts
    15
    My Mood
    Stressed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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?

  6. #6
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default 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.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  7. #7
    Junior Member
    Join Date
    Sep 2012
    Posts
    15
    My Mood
    Stressed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 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.

    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;
     
    	}
     
     
    }
    Last edited by Huw; September 20th, 2012 at 01:22 PM.

  8. #8
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default 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
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  9. The Following User Says Thank You to newbie For This Useful Post:

    Huw (September 20th, 2012)

  10. #9
    Junior Member
    Join Date
    Sep 2012
    Posts
    15
    My Mood
    Stressed
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: Help with a java question...

    Quote Originally Posted by newbie View Post
    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!

Similar Threads

  1. Challenging Java Question: Test your Java skill by grouping these terms
    By karthickk3 in forum Java Theory & Questions
    Replies: 3
    Last Post: July 18th, 2012, 10:10 PM
  2. Java EE Question
    By djl1990 in forum Java Theory & Questions
    Replies: 2
    Last Post: May 12th, 2012, 12:42 PM
  3. JAVA RMI question
    By rlk in forum Java Networking
    Replies: 6
    Last Post: March 21st, 2012, 02:22 PM
  4. help for this java question
    By marlontoyo in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 20th, 2011, 08:09 PM
  5. Java Question
    By NiCKYmcd in forum Java Theory & Questions
    Replies: 1
    Last Post: August 25th, 2010, 08:47 AM