• Post Reply Bookmark Topic Watch Topic
  • New Topic

assessment questions  RSS feed

 
Andrew Concilio
Ranch Hand
Posts: 30
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi
i am applying for entry level java positions and some of these companies make you do assessment exams once the test is done you only get the the result of the test and not a breakdown of the questions telling you what was right or what was wrong. 3 questions that got my attention (maybe because i felt that i have to guess) are below can someone kindly confirm if i am right and if not what would it be.
Thanks

1.
Int a=3; int b=0;
Switch (a) {
Case 1:
B = a + 2;
Case 2:
B = a + 3;
Case 3:
B = a + 4;
Case 4:
B = a + 5;
Case 5:
B = a + 6;
default:
B = a * 2;
}
// line A


When you execute the sample code above, what is the value of b when line A is reached?
o 0
o 5
o 6
o 8
o 9

my answer is 9

2.
At a minimum basic Java testing includes:

Functional – have all methods been called?
Procedural have all lines of code been called?
Decisional has every control point been evaluated?
Conditional has every Boolean expression been evaluated?
Performance does the code perform efficiently?

When you test a program and ensure that every line of code has been accessed, this basic testing is:
Regression
Performance
Procedural
Conditional
Functional

my answer is performance


3.
a friend passes along an applet from TrustedSoftware.com that has been signed using a private key, explaining that since the applet is from TrustSoftware.com and has been signed, it would acceptable to allow the applet full access to your hard drive. The email with the applet also contain a public key for you to verify. You verify the signature using the provided public key, and the verification passes.
o Is as trustworthy as TrustedSoftware.com
o Was signed using the private key that matched the provide public key
o Is corrupt and cannot be trusted
o Was not released by TrustedSoftware.com
o Cannot access your hard drive, since you have not registered your public key with Trustedsoftware.com

my answer is b

any help will be appreciated
 
fred rosenberger
lowercase baba
Bartender
Posts: 12563
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1) my answer is that b is 0. The switch is modifying B - a completely different variable.

2) it says "Procedural - have all lines of code been called" . it then asks "When you test a program and ensure that every line of code has been accessed,"

3) Personally, I don't think i would ever allow an applet full access to my hard drive.
 
Joel Christophel
Ranch Hand
Posts: 250
1
Chrome Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
fred rosenberger wrote:1) my answer is that b is 0. The switch is modifying B - a completely different variable.

Nice catch. They're almost certainly looking for the answer of 9, though.
 
Andrew Concilio
Ranch Hand
Posts: 30
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
2. Still not sure what the answer is
3. E is the answer? Cannot access your hard drive ....... ?
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Joel Christophel wrote: . . . Nice catch. They're almost certainly looking for the answer of 9, though.
Not at all, When they got rid of all the other compiler errors, they would have expected





6
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can you explain what your reasoning is for the answers that you think are correct?

The answer to the first question is definitely not 9. Note: You can type in this code in a small program and run it to see what the result is.
 
Andrew Concilio
Ranch Hand
Posts: 30
Eclipse IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
well jasper i was clueless on these 3 questions and i had to guess but this was my rezoning, again as a Jr developer i understand that i still have room to go and learn

question # 1 answer 9 because i was just following the math
question # 2 answer b (performance) because the sentence "When you test a program and ensure that every line of code has been accessed, this basic testing is?:" what i am understanding from this question is "when you test a program is every line of code is working" and if that is the question then the code is performing
question # 3 answer b it just made sence
 
Campbell Ritchie
Marshal
Posts: 56536
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Andrew Concilio wrote: . . . again as a Jr developer i understand that i still have room to go and learn

question # 1 answer 9 because i was just following the math
. . .
You are supposed to follow the programming. There is a very basic beginner's mistake in that code, which you are supposed to notice. And you are supposed to post the code as it was given, which means case not Case.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16059
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Question 1: Let's follow the program line by line (and let's ignore the fact that the case is wrong). What happens?

There's a switch statement. So, it chooses one of the cases, based on the value of a. As you can see, a is 3, so it goes to "case 3:".

There we see: b = a + 4. So, b becomes 3 + 4 = 7.

And then? This question is a trick question. There should be "break;" statements after the code in each case, but they are not there. That means that it will execute all cases below case 3 as well. So, it will do b = a + 5, b = a + 6, etc. upto and including the default case, which has b = a * 2.

So, what is the value of b at the end?

Question 2: With "performance testing", what is meant is testing if the program runs fast enough. Not if all lines do what they are supposed to do - that would be functional testing (to check if the program functions correctly). Read the descriptions above the question carefully! I agree with fred, see his answer above.

Question 3: "It just made sense"... you should be able to explain why it makes sense, just vague feelings are rarely accurate.

But I think the answer should indeed be b. The description says nothing about who's private key the applet was signed with, just that it was signed with some private key. That ofcourse doesn't automatically make it trustworthy. It could be anybody's private key.
 
Alex Mandelsson
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If they don't want to tell you solutions, I would try to browse for some online testing tools which could help you with answers on similar questions...There is a lot of webs which have similar problems like these java programming tests and which also provide answers. You just need to google a little bit, and from various sources you'll collect solid number of usual test questions on interviews with correct answers
 
Stuart A. Burkett
Ranch Hand
Posts: 679
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Edit: ignore - misread the post
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!