Find the output:
class Test {
protected int x, y;
}
class Main {
public static void main(String args[]) {
Test t = new Test();
System.out.println(t.x +
+ t.y);
}
}
Answers
Answered by
19
Answer:
⛄✨❣ _ I HOPE HELP YOU _❣✨⛄
Explanation:
Find the output:
class Test {
protected int x, y;
}
class Main {
public static void main(String args[]) {
Test t = new Test();
System.out.println(t.x ++ t.y);}}
Answered by
1
Q) Find the output:
class Test {
protected int x, y;
}
class Main {
public static void main(String args[]) {
Test t = new Test();
System.out.println(t.x +" "+ t.y);
} }
a) 1 0
b) 0 0
c) 1 1
d) 0 1
Option (b) 0 0, is the output of the given program code here.
- The protected member in a program of Java is accessible in all the classes of the same packages and inherited classes of other packages.
- But in the given program code Test and Main are in the same package so there is an access-related problem will arise.
- Integral variable value initialized as 0 in Java by the default constructor.
- So, that's why the output of the given code is 0 0.
#SPJ3
Similar questions
English,
3 months ago
English,
3 months ago
Science,
3 months ago
Social Sciences,
7 months ago
Math,
7 months ago
English,
10 months ago
India Languages,
10 months ago