Problem statement:
What will be the output of the following java code?
- public class ConstructorCall {
- int num = 200;
- public void run(int num) {
- this.num = num;
- }
- public void printE() {
- System.out.println(2 * num);
- }
- public static void main(String[] args) {
- ConstructorCall obj = new ConstructorCall();
- obj.run(10);
- obj.printE();
- }
- }
Output: 20
No comments:
Post a Comment