Hi. Sorry for bothering you but I'm having some problems with reference variables. Can someone
tell me the answers for the codes below. If I translated something wrong from my language to English please tell me and I will try to fix it.
OK, but we don't know why you picked those answers. For question, explain why you chose the answer. Otherwise, we have no way of knowing if you're getting right by accident, or why an answer might be wrong.
Joined: Dec 11, 2012
well that's why i'm asking for help. I gave my best shot but I'm asking for a second opinion or they might be the wrong answers.
For example in the second question String is an object but don't have an value like for example String b = "Hello" so my doubts are
if there was created an object or not.
2. There are none objects created because String isn't initialized with a value, so that object isn't created yet.
3. I have doubts here and I chose a) just because int is an primitive variable just like byte,short,long,double,float,boolean,char. But String isn't initializes so I don't know if
that variable is a reference or not
4. There was created an object because with the keyword new we crate objects and the synax is Object nameOfThatObject = new Object;
5.I chose a because as I said int is part of primitive(simple) variables of datatypes
3. Yes, c is not correct. b is a ref variable even if it currently does not have a reference.
4. new creates a new object. But the string literal also represents an object, likely from the string pool. So it depends if the people making the questions count that one or not. As I said, I think it's a poorly worded question.
Joined: Dec 11, 2012
I figured out and these are the answers
1. b) - String is an reference
2. a) - int is an primitive variable and String is an reference
3. a) - same as 2nd answer
4. b) - first String is lateral so it doesn't count as object, and second String strB = new String("hello"); - this is an object
5. b) - int is an simple datadype, String is not.
Thanks for your time
I’ve looked at a lot of different solutions, and in my humble opinion Aspose is the way to go. Here’s the link: http://aspose.com