File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Valentin's mock exam..

 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Can anyone please tell me where I can find Valentin's mock exam?
Thanks.
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There you go:
Val's mock exam
Good luck
 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Valentin,
Thanks.. Will try it out...
 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How can I check the answers in the mock exam? I clicked submit and it gave me a score but I was not able to see the correct answers...
Thanks.
 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The questions were tough.. Will it be this tough in the real exam also?
Thanks
 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hai Valentin,
The question below states that there are 2 correct answers... ButI think that only C is correct...
--------------------------------------------------
Question 16. What is the output of the following code when compiled and run? Select two correct answers.
public class Question16 {
public static void main(String[] args) {
int i = 2;
try {
if((i/=(int)Math.floor(Math.random())) > 1)
System.out.println("No arithmetic exception");
} catch (ArithmeticException ae){
System.err.println("Arithmetic exception caught");
}
}
}


A. Compilation error.
B. No arithmetic exception will never be printed.
C. The final value of i is 2.
D. The final value of i is 0.
E. The try-catch block is necessary for the code to compile.
-------------------------------------------------
Thanks
 
Thomas Paul
mister krabs
Ranch Hand
Posts: 13974
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sun par:
The question below states that there are 2 correct answers... ButI think that only C is correct...
((i/=(int)Math.floor(Math.random())) > 1)

Math.random() - Returns a double value with a positive sign, greater than or equal to 0.0 and less than 1.0.
So the result will always be less than 1.
Math.floor() - Returns the largest (closest to positive infinity) double value that is not greater than the argument and is equal to a mathematical integer
So it always truncate the result of Math.random() to zero.
Therefore the expression will always generate a divide-by-zero error. The correct answers are B and C.
 
sun par
Ranch Hand
Posts: 257
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for making things clear..
 
Valentin Crettaz
Gold Digger
Sheriff
Posts: 7610
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by sun par:
The questions were tough.. Will it be this tough in the real exam also?
Thanks

The real exam won't be that hard. I intentionally made this mock exam hard to provide a little more challenge for people who want to get this a little further and seek for a very good score.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic