❌ A. 10 ✅ B. 20 ❌ C. 30 ❌ D. Compilation error ❌ E. Runtime error ❌ F. None of the above
Explanation: The code defines a class MyClass with a private instance variable myVar, a constructor that initializes myVar, and getter and setter methods for myVar.
In the Main class, an object obj1 of MyClass is created with the value 10 passed as an argument to the constructor. Then, obj2 is assigned a reference to the same object as obj1. Next, the setMyVar() method is called on obj2 with a value of 20. Finally, the value of myVar in obj1 is printed.
Since obj1 and obj2 refer to the same object, calling setMyVar() on obj2 also changes the value of myVar in obj1. Therefore, the output will be 20.
❌ A. 10 ✅ B. 20 ❌ C. 30 ❌ D. Compilation error ❌ E. Runtime error ❌ F. None of the above
Explanation: The code defines a class MyClass with a private instance variable myVar, a constructor that initializes myVar, and getter and setter methods for myVar.
In the Main class, an object obj1 of MyClass is created with the value 10 passed as an argument to the constructor. Then, obj2 is assigned a reference to the same object as obj1. Next, the setMyVar() method is called on obj2 with a value of 20. Finally, the value of myVar in obj1 is printed.
Since obj1 and obj2 refer to the same object, calling setMyVar() on obj2 also changes the value of myVar in obj1. Therefore, the output will be 20.
Therefore, the correct answer is option 20.
BY Explanations “Top Java Quiz Questions”
Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283
Telegram is an aspiring new messaging app that’s taking the world by storm. The app is free, fast, and claims to be one of the safest messengers around. It allows people to connect easily, without any boundaries.You can use channels on Telegram, which are similar to Facebook pages. If you’re wondering how to find channels on Telegram, you’re in the right place. Keep reading and you’ll find out how. Also, you’ll learn more about channels, creating channels yourself, and the difference between private and public Telegram channels.
How To Find Channels On Telegram?
There are multiple ways you can search for Telegram channels. One of the methods is really logical and you should all know it by now. We’re talking about using Telegram’s native search option. Make sure to download Telegram from the official website or update it to the latest version, using this link. Once you’ve installed Telegram, you can simply open the app and use the search bar. Tap on the magnifier icon and search for a channel that might interest you (e.g. Marvel comics). Even though this is the easiest method for searching Telegram channels, it isn’t the best one. This method is limited because it shows you only a couple of results per search.