Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Linux Archive
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 01-15-2008, 10:17 PM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 01-15-2008, 10:56 PM
roots's Avatar
Moderator
 
Join Date: Jan 2008
Location: Dallas
Posts: 263
roots is on a distinguished road
these aren't no tough questions
__________________
dont worry newbie, we got you covered.
Bookmark Post in Technorati
Reply With Quote
  #3 (permalink)  
Old 01-15-2008, 11:52 PM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #4 (permalink)  
Old 01-15-2008, 11:57 PM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
these questions are 9 out of 60 total... these are just the ones I had trouble with =/
Bookmark Post in Technorati
Reply With Quote
  #5 (permalink)  
Old 01-15-2008, 11:58 PM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
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.
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #6 (permalink)  
Old 01-16-2008, 02:07 AM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
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?
__________________
//Haha javac, can't see me now, can ya?
Bookmark Post in Technorati
Reply With Quote
  #7 (permalink)  
Old 01-16-2008, 02:21 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
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..
Bookmark Post in Technorati
Reply With Quote
  #8 (permalink)  
Old 01-16-2008, 03:10 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
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.
Bookmark Post in Technorati
Reply With Quote
  #9 (permalink)  
Old 01-16-2008, 03:22 AM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
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.
__________________
//Haha javac, can't see me now, can ya?
Bookmark Post in Technorati
Reply With Quote
  #10 (permalink)  
Old 01-16-2008, 03:27 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
then 1 is b?
Bookmark Post in Technorati
Reply With Quote
  #11 (permalink)  
Old 01-16-2008, 03:31 AM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
Yes, it is
__________________
//Haha javac, can't see me now, can ya?
Bookmark Post in Technorati
Reply With Quote
  #12 (permalink)  
Old 01-16-2008, 03:35 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
thanks a lot! lol.. 1 down.. 8 to go
Bookmark Post in Technorati
Reply With Quote
  #13 (permalink)  
Old 01-16-2008, 04:23 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
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 =/
Bookmark Post in Technorati
Reply With Quote
  #14 (permalink)  
Old 01-16-2008, 04:27 AM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 841
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
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?
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
  #15 (permalink)  
Old 01-16-2008, 04:30 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
Gonna go with c. an assignment operation..
Bookmark Post in Technorati
Reply With Quote
  #16 (permalink)  
Old 01-16-2008, 04:36 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
  #17 (permalink)  
Old 01-16-2008, 11:46 AM
tim's Avatar
tim tim is offline
Senior Member
 
Join Date: Dec 2007
Location: South Africa
Posts: 334
tim is on a distinguished road
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.
Code:
c. char Initial; // <- see no equal sign
Hope this helped
__________________
If your ship has not come in yet then build a lighthouse.
Bookmark Post in Technorati
Reply With Quote
  #18 (permalink)  
Old 01-17-2008, 12:17 AM
gibsonrocker800's Avatar
Senior Member
 
Join Date: Nov 2007
Location: New York
Posts: 143
gibsonrocker800 is on a distinguished road
Send a message via AIM to gibsonrocker800
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).
__________________
//Haha javac, can't see me now, can ya?
Bookmark Post in Technorati
Reply With Quote
  #19 (permalink)  
Old 01-17-2008, 12:20 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
Thanks for all the help guys.. I worked some of the problems out and i got a 95% on the homework :]
Bookmark Post in Technorati
Reply With Quote
  #20 (permalink)  
Old 01-17-2008, 12:21 AM
Member
 
Join Date: Dec 2007
Posts: 13
passage is on a distinguished road
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
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


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


All times are GMT +3. The time now is 02:34 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org