Menu
Topics Index
...
`

Literals2628


If you need explanation Read this topic

If you need Answer Take test on this topic

Literals2628
What will be the output of the following program?
public class Student {
    public static void main(String[] args) {
        String name = "Raju", marks = "1";
        String section = "A";
        marks = 560;
        System.out.println("Name: " + name);
        System.out.println("Section: " + section);
        System.out.println("Marks: " + marks);
    }
}

A. Name: Raju
Section: A
Marks: 560
B. Name: Raju
Section: A
Marks: 1560
C. Compilation Error
D. Runtime Error
Topic: Literals 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.

compilation error since marks is declared twice and being string type it is assigned integer in 5th line hence answer is  c

Posted by Sangeetha Ptl    2014-03-12 03:50:19


Ans C:marks is a String varible ...here we mention string and int both values so...incompatible type problm will occures..

Posted by Ashok Reddi    2014-03-12 03:53:46


Ans : C because of TYPE MISMATCH at marks=560  in between STRING  and int

Posted by Deepak Kumar Yadav    2014-03-12 16:13:47


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

Posted by Merit Campus    2014-03-13 04:30:56


© meritcampus 2019

All Rights Reserved.

Open In App