Menu
Topics Index
...
`

My expensives


If you need explanation Read this topic

If you need Answer Take test on this topic

My expensives
What will be the output of the following program?
public class Expensives {
    public static void main(String[] args) {
        String textBook = "500";
        Short allInOne = new Short(textBook);
        Short xerox = Short.parseShort(textBook);
        short travel = Short.parseShort(textBook, 16);
        System.out.println(textBook + " " + allInOne + " " + xerox + " " + travel);
    }
}

A. 500 500 500 1F4
B. 500 500 500 1280
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 is A...the value of textbook is parsed to short and converted to short and printed as 500 500 500 1F4

Posted by Badam Swathi    2014-08-05 03:53:29


a .

Posted by Shubham Bansal    2014-08-05 03:58:22


B.

Posted by Pothuluri Venkateswarlu    2014-08-05 04:04:51


ans a.
value string s parsed to short and printd

Posted by NagaRaj Nataraj    2014-08-05 05:09:46


answer a.
pharsin usd n printd

Posted by Maheshwari Natarajan    2014-08-05 05:25:56


No winner for this dose. Correct option is 'B' :(.TextBook(500) is in radix 16 it converts in to radix 10 i.e (500)16-->(1280)10 so it will give output as "500 500 500 1280".

Posted by Merit Campus    2014-08-06 05:03:55


© meritcampus 2019

All Rights Reserved.

Open In App