Results 1 to 20 of 22
- 01-15-2008, 08:17 PM #1
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
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
- 01-15-2008, 08:56 PM #2
these aren't no tough questions
dont worry newbie, we got you covered.
- 01-15-2008, 09:52 PM #3
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)
- 01-15-2008, 09:57 PM #4
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
these questions are 9 out of 60 total... these are just the ones I had trouble with =/
- 01-15-2008, 09:58 PM #5
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)
- 01-16-2008, 12:07 AM #6
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?
- 01-16-2008, 12:21 AM #7
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
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..
- 01-16-2008, 01:10 AM #8
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
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.
- 01-16-2008, 01:22 AM #9
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.
- 01-16-2008, 01:27 AM #10
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
then 1 is b?
- 01-16-2008, 01:31 AM #11
Yes, it is
- 01-16-2008, 01:35 AM #12
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
thanks a lot! lol.. 1 down.. 8 to go
- 01-16-2008, 02:23 AM #13
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
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 =/
- 01-16-2008, 02:27 AM #14
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)
- 01-16-2008, 02:30 AM #15
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
Gonna go with c. an assignment operation..
- 01-16-2008, 02:36 AM #16
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
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
- 01-16-2008, 09:46 AM #17
Trick question
Hi passage
The modifiers (final and private) are there to confuse you. The question said:
Look at them all. Each one declares a variable but only one does not get initialized.
Originally Posted by passage
Hope this helped :pJava Code:c. char Initial; // <- see no equal sign
Eyes dwelling into the past are blind to what lies in the future. Step carefully.
- 01-16-2008, 10:17 PM #18
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).
- 01-16-2008, 10:20 PM #19
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
Thanks for all the help guys.. I worked some of the problems out and i got a 95% on the homework :]
- 01-16-2008, 10:21 PM #20
Member
- Join Date
- Dec 2007
- Posts
- 13
- Rep Power
- 0
Similar Threads
-
Removal of Homework Requests
By CaptainMorgan in forum Suggestions & FeedbackReplies: 14Last Post: 08-03-2008, 09:21 PM -
Problem using thread +rmi in my homework
By IbrahimAbbas in forum Threads and SynchronizationReplies: 10Last Post: 04-14-2008, 09:24 PM -
I need help with my java servlet homework(average)
By jellyfish888 in forum Java ServletReplies: 2Last Post: 12-23-2007, 09:57 PM -
Help with my java servlet homework
By jellyfish888 in forum Java ServletReplies: 2Last Post: 12-21-2007, 05:41 PM -
Homework PREREQUISITE Problem
By ChrisC in forum New To JavaReplies: 7Last Post: 11-27-2007, 05:36 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks