1.

Which of the following is a best practice to measure time taken by a process for execution?(a) System.currentTimeMillis()(b) System.nanoTime()(c) System.getCurrentTime()(d) System.getProcessingTime()I got this question in an internship interview.This is a very interesting question from Coding best practices in portion Autoboxing & Miscellaneous of Java

Answer»

Right ANSWER is (B) System.nanoTime()

The best explanation: System.nanoTime takes AROUND 1/100000 TH of a second WHEREAS System.currentTimeMillis takes around 1/1000th of a second.



Discussion

No Comment Found

Related InterviewSolutions