Menu
Question Index
...

What is the output of the following program?

import java.io.*;
import java.util.*;

public class Dhavan {
    public static void main(String[] args) {
        Properties properties = new Properties();
        properties.put("AP", "Hyd");
        properties.put("Tamilnadu", "Chennai");
        properties.put("MP", "Bhopal");
        Properties properties2 = new Properties(properties);
        properties2.put("Goa", "goa");
        properties2.put("Karnataka", "Bangulur");
        properties2.put("Kerala", "Kochin");
        properties2.put("India", 28); // LINE A
        System.out.print(properties.size() + " " + properties2.size() + " ");
        try {
            FileOutputStream fout = new FileOutputStream("test.txt");
            properties2.store(fout, "Book");
            fout.close();
        } catch (Exception e) {  }
        properties2.put("Orissa", "Bhuvane");
        properties.put("Maharasta", "Mumbai");
        System.out.print(properties.size() + " " + properties2.size() + " ");
        try {
            FileInputStream fin = new FileInputStream("test.txt");
            properties2.load(fin);
            fin.close();
        } catch (Exception e) { }
        System.out.println(properties.size() + " " + properties2.size());
        System.out.print("Capital :" + properties2.getProperty("Maharasta"));
    }
}


3 4 4 5 4 5
Capital :null
3 4 4 5 4 5
Capital :Mumbai
3 4 4 5 3 4
Capital :Mumbai
3 4 4 4 3 4
Capital :Mumbai
3 4 4 4 3 4
Capital :null
Compilation Error at LINE A or Runtime Error

Doubts

Problems

Topic: Java FileOutputStream

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App