Consider the code:

public class MyCalculator {
    public static void main(String[] args) {
     // Insert here
    }
}
Which of the following should be inserted in the code to print 3.1416?
Explanation
Method System.out.printf() prints formatted text, Math.PI is a constant for PI number and correct format string is %6.4f which stands for "Print a floating point number prepending spaces to occupy not less then 6 characters with precision of 4 numbers after dot."

Follow CodeGalaxy

Mobile Beta

Get it on Google Play
Send Feedback