Last week, we had the author of TDD for a Shopping Website LiveProject. Friday at 11am Ranch time, Steven Solomon will be hosting a live TDD session just for us. See for the agenda and registration link
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Should we expect such questions?

 
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
HI,
consider the following question?

What will be the result of attempting to compile and run the following class?
public class NumberTest
{
public static void main(String args[])
{
System.out.println(0x10 + 10 + 010);
}
}

Select 1 correct option.
a Compilation error because of the expression 0x10 + 10 + 010.
b When run, the program will print "28 ".
c When run, the program will print "30 ".
d When run, the program will print "34 ".
e When run, the program will print "36 ".

The code compiles fine and when run prints 34 and not "34 ".
but the options herein say that it will print "<result>".

and I had seen the same question in another mock wherein they had not used inverted commas in the options.

here I had no other choice so i selected d as answer. but in the real exam we may have some other better choice...

should we expect such questions in the exam? and if yes how to solve those?

Thanx
Sandy
 
Ranch Hand
Posts: 1902
Hibernate Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The basic answer is 'yes', you should expect questions like this.

By and large, it won't be phrased the way option A was, but more likely as 'Compilation error due to line 5' or somesuch. The quotation marks are just for clarification as to where the exact string starts and stops for the output, not because it's going to output quotation marks.
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Question 35 of 110
How can you declare a method someMethod() such that an instance of the class is not needed to access it and all the members of the same package have access to it.

a public static void someMethod()
b static void someMethod()
c protected static void someMethod()
d void someMethod()
e protected void someMethod()

Here in the above mentioned code it says that all the members of the same package have acces to it. but it does not says that only the members of the same package have access to it.
so we can say that both the options a ,b and c (edited later)can be applicable.
What if the question asks to select only one option.

Should we expect such questions in the Real exam?
Thanks
[ September 27, 2005: Message edited by: Sandeep Chhabra ]
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
This is a question from JQPlus Mock Question ID: 1043963785218

Consider the following class:


Which of the following statements are correct regarding the above class?

Select 1 correct option.
a This is an invalid implementation of hashCode() method with respect to the given equals() method.

b Only one of the Info objects will be stored in the HashMap.

c Both the objects will be stored in the HashMap.

d An exception will be thrown at run time at line //2.

The Correct answer is a.
This questions asks to select only 1 option. According to me c is also correct.

Should we expect such questions in Real Exam?

Thanks
 
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi,

for Question 35 of 110 on access modifiers, if you agree on broader access than (default), u could also include protected.

And for the last one with the hashcode(), perhaps I miss something but s1.hashCode() seems perfectly correct to me.

2 equals object must have the same hashCode but
2 objects with the same hashCode dont garantee that they are equals

For optimisation, u better have the last case not too common, that s all. (Anyone correct me if I am wrong )
[ September 27, 2005: Message edited by: Cyrano DeBergerac ]
 
Ranch Hand
Posts: 47
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
How's option a correct?
example:
Info info1 = new Info("aaa", "aaa", "ccc");
Info info2 = new Info("a", "aaaaa", "ccc");
info1.equals(info2) = true
but info1.hashcode != info2.hashcode which breaks the rule of

2 equals object must have the same hashCode

 
Eric Janssens
Ranch Hand
Posts: 53
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thx, I need to pay more attention
[ September 27, 2005: Message edited by: Cyrano DeBergerac ]
 
Sandeep Chhabra
Ranch Hand
Posts: 340
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
Thanks for your replies.
But my questions was should we expect such question in the exam.
Here the options for both the questions were vague and more than one options can be easily applicable. But the questions ask to select only ONE.

So are we going to get such questions in the exam ?
 
Ranch Hand
Posts: 220
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Sandeep Chhabra:
Hi,
Thanks for your replies.
But my questions was should we expect such question in the exam.
Here the options for both the questions were vague and more than one options can be easily applicable. But the questions ask to select only ONE.

So are we going to get such questions in the exam ?



YES

but you'll have to choose the BEST option. Ask Bert about it- He's the one who'll give you the best answer.
[ September 28, 2005: Message edited by: Akshay Kiran ]
 
Warning! Way too comfortable! Do not sit! Try reading this tiny ad instead:
free, earth-friendly heat - a kickstarter for putting coin in your pocket while saving the earth
https://coderanch.com/t/751654/free-earth-friendly-heat-kickstarter
reply
    Bookmark Topic Watch Topic
  • New Topic