Menu
Topics Index
...
`

Evening


If you need explanation Read this topic

If you need Answer Take test on this topic

Evening
What will be the output of the following program?
import java.io.*;
public class Evening {
    public static void main(String[] args) {
        CharSequence cs = "Good~Evening";
        PrintStream ps = new PrintStream(System.out);
        ps.append(cs, 5, 12);
        ps.append(cs, 0, 4);
    }
}

A. Evening Good
B. EveningGood
C. EveningGood~
D. ~EveningGood~
E. Compilation Error or Runtime Error
Topic: Java PrintStream Class

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 B ..first it appends evening and then good so output is EveningGood

Posted by Anvesh Athmakuri    2014-03-14 03:47:06


Ans is B the PrintStream will take charsequence as input and ps object appends index 5 -12 chars  and next it appends index 0-4 that is good so it prints EveningGoood

Posted by Naga Sinst    2014-03-14 03:51:43


C

Posted by Gopinath Manchikanti    2014-03-15 08:31:59


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

Posted by Merit Campus    2014-03-17 04:26:02


© meritcampus 2019

All Rights Reserved.

Open In App