Menu
Topics Index
...
`

Output will print or not


If you need explanation Read this topic

If you need Answer Take test on this topic

Output will print or not
What will be the output of the following program?
public class StringLiterals {
    public static void main(String[] args) {
        String str = "Hai I scored";
        String number = "98";
        String percentage = "76.9";
        String special_char = "%";
        String grade = "A";
        System.out.print(str + " - ");
        System.out.print(number + " - ");
        System.out.print(percentage);
        System.out.print(special_char + " - ");
        System.out.print(grade);
    }
}

A. Hai I scored
B. Hai I scored - 98
C. Hai I scored - 98 - 76.9% - A
D. Some other output
E. Compilation Error or Runtime Error
Topic: String Literal In Java

If you need explanation Read this topic

If you need Answer Take test on this topic

User comments below. All of them might not be correct.

ans is c  ist it will print  str then - then number followed by - percentage specialchar - grade

Posted by Aparna Kanjarla    2014-07-29 12:44:02


c. is right answer.
every statement will executed

Posted by Shubham Bansal    2014-07-29 12:44:37


ans C, one by one sop is going print and it adds a symbol  "- ", finally it Prints Hai I Scored - 98 - 76.9% - A.

Posted by Damu Surya    2014-07-29 12:45:18


C

Posted by Datta Sai Krishna    2014-07-29 12:45:31


Answer c: Because there is no error it execute all statements there is no println statement they are printed in same line

Posted by Venkatesh Kotte    2014-07-29 12:46:20


C :this is simple

Posted by Mani Deep    2014-07-29 12:48:21


Answer is C as there are no println methods in the program which means printing each statement in a new line but print method prints statements in a same line not in a new line.

Posted by Sai Avinash    2014-07-29 12:52:36


C

Posted by Vineeth Parasa    2014-07-29 13:43:16


c

Posted by Prabhakar Reddy    2014-07-29 13:53:13


Congratulations Aparna Kanjarla. You are this dose winner. We will send you the link using which you can claim your recharge.

Posted by Merit Campus    2014-07-30 04:19:46


© meritcampus 2019

All Rights Reserved.

Open In App