Menu
Topics Index
...
`

System Demo


If you need explanation Read this topic

If you need Answer Take test on this topic

System Demo
What will be the output of the following program?
public class SystemDemo {
    public static void main(String[] args) {
        String str = System.getProperty("dog", "cat");
        System.out.print(str + ", ");
        str = System.getProperty("", "duck");
        System.out.print(str);
    }
}

A. cat, duck
B. dog, (EMPTY)
C. Compilation Error 
D. Runtime Error
Topic: Java Environment Properties

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 as the key value is not present in the list the default values are returned.they are cat  duck

Posted by Manasa Jyothi Sree    2014-06-02 04:36:06


Ans:D In System.getProperty("","duck"); Here Key should not be empty. If we giving empty value then it gives Runtime error

Posted by Indrasena Reddy    2014-06-02 04:52:26


Answer : D
getProperty() will not accept null keys

Posted by Deepak Kumar Yadav    2014-06-02 05:57:10


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

Posted by Merit Campus    2014-06-03 04:34:09


© meritcampus 2019

All Rights Reserved.

Open In App