Menu
Topics Index
...
`

ValueOf


If you need explanation Read this topic

If you need Answer Take test on this topic

ValueOf
What will be the output of the following program?
public class ValueOfInWrappers {
    public static void main(String[] args) {
        String input = "+127";
        Byte copy = Byte.valueOf(input);
        String str = input + " " + copy;
        System.out.println(str);
    }
}

A. +127 127
B. +127 +127
C. Compilation Error
D. Runtime Error
Topic: Creating Objects for Primitive Data Types (Byte, Short)

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-A,Value of method will give 127 and we are adding this with input .So answer is A.

Posted by Abhishek Pollishetty    2014-06-12 03:44:38


Ans:):A,Because ValueOf() returns String reprsentation of argument

Posted by Rajashekar Chelpuri    2014-06-12 03:53:36


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

Posted by Merit Campus    2014-06-13 04:10:07


© meritcampus 2019

All Rights Reserved.

Open In App