Forums Register Login

doubts from Sarga mock exam

+Pie Number of slices to send: Send
1) Given the following class definition:
class A {
protected int i;
A(int i) {
this.i = i;
}
}
Which of the following would be a valid inner class for this class?
Select all valid answers.
a) class B {
}
b) class B extends A {
}
c) class B {
B() {
System.out.println("i = " + i);
}
}
d) class B {
class A {
}
}
e) class A {
}
I select A & C.They said only A.Am I missing something?
Please un adive.
+Pie Number of slices to send: Send
class A {
protected int i;
A(int i) {
this.i = i;
}
class B {
B() {
System.out.println("i = " + i);
}
}
public static void main(String args[])
{
B b = new A(10).new B();
}
}
U r right the ans is A C.
the ans they have given are wrong u can try the above code
+Pie Number of slices to send: Send
Thanks a lot Bhavana...
I've already test it and I saw no compile problem but I want to saw another opinion.
+Pie Number of slices to send: Send
b also compiles
Those are the largest trousers in the world! Especially when next to this ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 954 times.
Similar Threads
inner class
plz explain
Inner Class
About Inner class!
inner class
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 15, 2024 23:54:49.