Menu
Question Index
...

What will be the output of the following program?

public class Rose {
    public Rose(String name) {
        System.out.println("Passed Name is :" + name);
    }
    public static void main(String[] args) {
        Rose myRose = new Rose("red");
        myRose = new Rose("white");
    }
}


Passed Name is :red
Passed Name is :white
Passed Name is :red
Passed Name is :white
Compilation Error or Runtime Error

Doubts

Problems

Topic: Create Objects Using Constructors In Java

Read this topic
Take test on this topic

0
Wrong
Score more than 2 points

© meritcampus 2019

All Rights Reserved.

Open In App