• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Brainbench Test

 
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi last time i am given brainbench test there they ask following question
tell me which option is correct.

Sample Code
class B extends A {
}
Referring to the above, when classes B and A are in the same package, what is the meaning of "extends"?
Choice 1
B is a superclass of A.
Choice 2
B is directly derived from A and all non-private methods and attributes defined in A are also available to B objects.
Choice 3
It invokes the default constructor of A when the default constructor of B is invoked.
Choice 4
B belongs to the same package as A.
Choice 5
The source code for B is in the same file as A.
 
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Choice 2
 
Ranch Hand
Posts: 1272
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think choices 2 and 3. N'est pas?
 
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mike,

I would nominally and normally agree with you that the correct answers are 2 and 3. I've learned, however, that many Java programmers do not cosider a no-arg constructor as a default constructor. So if Choice 3 read "It invokes the no-arg constructor of A when the default constructor of B is invoked" rather than "It invokes the default constructor of A when the default constructor of B is invoked", I think you'd have unanimous support on this board.

In lieu of the board's support, you have mine. With that and $0.50, you can get a can of Coke.
 
Doyle Matt
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Guys guys guys, have you read the question? the question is asking what does the "extends" key word means. Choice 3 is a correct "statement" but I guess it can't answer what extends mean right? Therefor choice 2 is the only answer. Its a good thing that the actual exam presents the number of correct answers.
 
Joe Borderi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"Guys guys guys, have you read the question? the question is asking what does the "extends" key word means."

That's an interesting take. If your interpretation is true, however, I like the question as an SCJP test question even less. The way that I, and I am guessing Mike and many others, interpret "what does (fill in the blank) mean?" is "what is (are) the implications?" The question in its meaning becomes even more debatable.

I guess I am beginning to see that the best questions for these exams are the ones that you can run through a compiler. Initially, I didn't like compiler-answered questions at all because I think any programmer with a single course in Java should be able to answer them, and in the working world, programmers rely on the compiler to catch all those silly mistakes. In brief, the certifications based on compiler catchable questions really didn't certify much. Now I see the difficulty in constructing an objective test that would certify a programmer's proficiency.
 
Doyle Matt
Ranch Hand
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I guess I am beginning to see that the best questions for these exams are the ones that you can run through a compiler.

The "compiler questions" only goes as far as checking your proficiency in the language. There are also "runtime questions" that can't be easily checked by a compiler.
 
mohan gavande
Ranch Hand
Posts: 39
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Thanks to all for replying me.
There is one another quetion is asked like this that is

Sample Code
1: import java.io.*;
2: class PrintThread extends Thread {
3: private static Object o = new Object();
4: private static DataOutputStream out = //... set to some output file
5: private int I;
6:
7: public PrintThread(int I) {
8: this.I = I;
9: }
10: public void run() {
11: while(true) {
12: try {
13: out.writeBytes("Hello all from thread " + I +"\r\n");
14: } catch (Exception e) {}
15: }
16: }
17: public static void main(String[] s) {
18: for (int i = 0; i < 5; i++ ) {
19: (new PrintThread(i)).start();
20: }
21: }
22: }
How could you ensure that each line of output from the above program came from an individual thread?
Choice 1
Add the "synchronized" modifier to the DataOuputStream "out" variable declaration.
Choice 2
Insert the following line between line 12 and 13:
synchronized(o) {

and this line between line 13 and 14
}
Choice 3
Insert the following code between line 11 and 12:
yield();
Choice 4
Insert the following code between line 11 and 12:
try {
sleep(100);
} catch(Exception e) {}
Choice 5
Make the run method "synchronized".
 
Joe Borderi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"The "compiler questions" only goes as far as checking your proficiency in the language. There are also "runtime questions" that can't be easily checked by a compiler."

Yes, but they must be put through the compiler first before reaching runtime . My point is that the test should only ask questions that can be tested in Java.

Apparently, Sun dealt with a similar brouhaha with a test question regarding whether true, false, and null were keywords and felt compelled to clarify this in its published exam objectives: "Note: there will not be any questions regarding esoteric distinctions between keywords and manifest constants."

BTW, since I am arguing by analogy and the argument is only as valid as the situations are similar, let me point out a difference: Sun has in its documentation what the keywords are, and every introductory book on Java I have ever seen has a table of the keywords. In truth, there should be no debate whether true, false, and null are keywords. (Can such a strong argument be made for the definitive meaning of "default constructor"?)

I surmise that Sun ultimately decided against the "esoteric distinctions" questions because once true, false, and null are put through a compiler (and JVM) what really is the difference in whether a programmer thinks of these as keywords or manifest constants?

Shouldn't the interpretation of "default constructor" as "only compiler supplied" or "any no-arg constructor" fall under the "esoteric distinctions" clause? Does a programmer's interpretation of "default constructor" using either definition matter a lick to the compiler or runtime interpreter?
 
reply
    Bookmark Topic Watch Topic
  • New Topic