Page 1 of 2 12 LastLast
Results 1 to 20 of 22
  1. #1
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default Tough Homework Questions, PLEASE HELP!

    Hello! Iím fairly new to the forum and I was wondering if I could get some help with a couple of tough homework questions that I have to do. If you could also provide a brief explanation that would be great but you donít have to. Thanks soo much!!!

    1. What will print to screen?

    System.out.println(Object1);

    a. Hexidecimal code of the object's source code
    b. Object1's Class name and Object1's memory address
    c. Nothing

    2. Which of the following is a literal string?

    a. new String(a)
    b. String
    c. Char String
    d. "Hello Philip"

    3. What is the purpose for the following code segment?

    somevariable = expression;

    a. creates a method
    b. compares values
    c. an assignment operation
    d. finds the variable in the expression

    4. Which is a variable declaration only?

    a. final float = 12;
    b. private int MyNumber = 67;
    c. char Initial;
    d. int Age = 55;

    5. Which of the following are valid commands? (MORE THAN ONE ANSWER!)

    a. System.out.println("The amount is " + 99);
    b. String values = 98 + 45;
    c. String numbers = "7.8" + " 9.0 " + " 3.4 ";
    d. String money = "$" + 45.90 + 22.45;


    6. What primitive data type should be used for the following value?

    true

    a. float
    b. Boolean
    c. char
    d. int

    7. What type of constant is '-49'? (POSSIBLY MORE THAN ONE ANSWER!)

    a. neither
    b. symbolic
    c. literal
    d. both

    8. If a decimal is changed to an int, _________.

    a. The decimal is truncated
    b. it cannot be changed
    c. The decimal is rounded up
    d. the decimal is rounded down

    9. What is the output?

    System.out.println("my numbers: " + 4 + 5);

    a. my numbers:
    b. invalid command error
    c. my numbers: 45
    d. my numbers: 9

  2. #2
    roots's Avatar
    roots is offline Moderator
    Join Date
    Jan 2008
    Location
    Dallas
    Posts
    293
    Rep Power
    7

    Default

    these aren't no tough questions
    dont worry newbie, we got you covered.

  3. #3
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    Quote Originally Posted by passage View Post
    Hello! Iím fairly new to the forum and I was wondering if I could get some help with a couple of tough homework questions that I have to do. If you could also provide a brief explanation that would be great but you donít have to. Thanks soo much!!!

    You're joking, right? Usually I welcome people to our forums graciously... in your case, you've started off the wrong way. You need to attempt these yourself. These are your questions, your homework - not ours.
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  4. #4
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    these questions are 9 out of 60 total... these are just the ones I had trouble with =/

  5. #5
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    Quote Originally Posted by passage View Post
    these questions are 9 out of 60 total... these are just the ones I had trouble with =/
    How about you tell us what you're beliefs are on each one and why you would choose one answer over another.
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  6. #6
    gibsonrocker800's Avatar
    gibsonrocker800 is offline Senior Member
    Join Date
    Nov 2007
    Location
    New York
    Posts
    143
    Rep Power
    0

    Default

    I mean this in a non-insulting way, but.. I don't understand how you can have 60 questions and get stuck on 9 of the most basic questions. How basic were the other questions?

  7. #7
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    Um they pretty easy/basic.. these were basically the ones that I couldn't find the answers to in the textbook.. that's why I'm lost..

  8. #8
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    like...

    1. i have absolutely no idea, the text does not specify.
    2. im assuming it's c b/c Char signifies 1 character right? and String is 1 character
    3. i know it does not create a method.. but otherwise all i really know is that it is a declaration which is signified by the ;
    4. the text does not provide examples of a variable declaration
    5. i'm totally lost on this one ..
    6. since true is one character im guessing you use char?
    7. im pretty sure it's both
    8. i just know that the decimal is not rounded up.. otherwise..
    9. i know it isn't the one with "9".. is it my numbers: 45?

    I know this is my homework.. but this AP Java Class is killing me this year and the text is very hard to follow as I have no background in Java and was forced into the class. I would really appreciate anyone's help. Thanks a lot.

  9. #9
    gibsonrocker800's Avatar
    gibsonrocker800 is offline Senior Member
    Join Date
    Nov 2007
    Location
    New York
    Posts
    143
    Rep Power
    0

    Default

    What book are you using? It sounds like a piece of trash the way you describe it lol. Let me explain some things, and see if you can come up with the answers. System.out.println() calls toString() on its parameters (which are the things inside of the parentheses). Now, if a certain object does not have a toString() method defined, the default is that it prints the class name and memory location. Let's say that Object1 is a class. If i define toString() in this class to make it so that it prints out a number, calling System.out.println(Object1) is going to print whatever you defined toString() to be. I wouldn't worry about this too much, as you are still learning the basics, but just know that, by default, toString() prints the class name and memory location.

    Using the equals sign is assigning the first expression to the second.

    Variable declaration is just creating a new variable but not defining it.


    With this knowledge in mind, see if you can do the questions. Otherwise, look up these things online. Your book must really be crappy because these are all basic concepts that must be grasped.

  10. #10
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    then 1 is b?

  11. #11
    gibsonrocker800's Avatar
    gibsonrocker800 is offline Senior Member
    Join Date
    Nov 2007
    Location
    New York
    Posts
    143
    Rep Power
    0

    Default

    Yes, it is

  12. #12
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    thanks a lot! lol.. 1 down.. 8 to go

  13. #13
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    i figured out that true would certainly be a boolean primitive data type b.c the range for bollean is true or false.... can anyone explain number 3 for me... the text just mentions that it is a declaration, nothing more =/

  14. #14
    CaptainMorgan's Avatar
    CaptainMorgan is offline Moderator
    Join Date
    Dec 2007
    Location
    NewEngland, US
    Posts
    835
    Rep Power
    9

    Default

    Quote Originally Posted by gibsonrocker800 View Post
    Using the equals sign is assigning the first expression to the second.

    Hmm... what do you think passage?
    Vote for the new slogan to our beloved Java Forums! (closes on September 4, 2008)
    Want to voice your opinion on your IDE/Editor of choice? Vote now!
    Got a little Capt'n in you? (drink responsibly)

  15. #15
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    Gonna go with c. an assignment operation..

  16. #16
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    4. Which is a variable declaration only?

    a. final float = 12;
    b. private int MyNumber = 67;
    c. char Initial;
    d. int Age = 55;

    i know it's not b...

    the book says a declaration always ends with a semi-colon, which they all do... it also says that public or private cannot be used in declarations of local variables.. which is why i obviously ruled out b.

    i also know that an initialized final "variable" is not actually a variable but it's really a constant because when it's declared final.. the values cannot change. that leaves me with c. and d.

    i wanna say int Age = 55; because char Initial; looks incorrects but i need further explanation

  17. #17
    tim's Avatar
    tim
    tim is offline Senior Member
    Join Date
    Dec 2007
    Posts
    435
    Rep Power
    7

    Default Trick question

    Hi passage

    The modifiers (final and private) are there to confuse you. The question said:
    Quote Originally Posted by passage
    Which is a variable declaration only?
    Look at them all. Each one declares a variable but only one does not get initialized.
    Java Code:
    c. char Initial; // <- see no equal sign
    Hope this helped :p
    Eyes dwelling into the past are blind to what lies in the future. Step carefully.

  18. #18
    gibsonrocker800's Avatar
    gibsonrocker800 is offline Senior Member
    Join Date
    Nov 2007
    Location
    New York
    Posts
    143
    Rep Power
    0

    Default

    passage, you need to buy a new book. I've never heard of a book that just doesn't explain assignment. or variable initialization. What book are you using (i'd like to purchase one so i can burn it, unless... the book is ok but you're not understanding it).

  19. #19
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    Thanks for all the help guys.. I worked some of the problems out and i got a 95&#37; on the homework :]

  20. #20
    passage is offline Member
    Join Date
    Dec 2007
    Posts
    13
    Rep Power
    0

    Default

    umm im using Java Methods A & AB: by litvin and litvin.. i think its a more advanced book and i have no background in java.. it's meant for an AP Java Class

Page 1 of 2 12 LastLast

Similar Threads

  1. Removal of Homework Requests
    By CaptainMorgan in forum Suggestions & Feedback
    Replies: 14
    Last Post: 08-03-2008, 10:21 PM
  2. Problem using thread +rmi in my homework
    By IbrahimAbbas in forum Threads and Synchronization
    Replies: 10
    Last Post: 04-14-2008, 10:24 PM
  3. I need help with my java servlet homework(average)
    By jellyfish888 in forum Java Servlet
    Replies: 2
    Last Post: 12-23-2007, 10:57 PM
  4. Help with my java servlet homework
    By jellyfish888 in forum Java Servlet
    Replies: 2
    Last Post: 12-21-2007, 06:41 PM
  5. Homework PREREQUISITE Problem
    By ChrisC in forum New To Java
    Replies: 7
    Last Post: 11-27-2007, 06:36 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •