1. package com.udayan.ocp;
2.
3. import java.util.stream.Stream;
4.
5. public class Test {
6. public static void main(String[] args) {
7. Stream
8. stream.sorted().forEach(System.out::println);
9. }
10. }
Which of the following needs to be done, so that output is:
d
cc
bbb
aaaa
1. package com.udayan.ocp;
2.
3. interface Printer1 {
4. default void print() {
5. System.out.println("Printer1");
6. }
7. }
8.
9. class Printer2 {
10. public void print() {
11. System.out.println("Printer2");
12. }
13. }
14.
15. class Printer extends Printer2 implements Printer1 {
16.
17. }
18.
19. public class Test {
20. public static void main(String[] args) {
21. Printer printer = new Printer();
22. printer.print();
23. }
24. }
What will be the result of compiling and executing Test class?
1. package com.udayan.ocp;
2.
3. class Player {
4. String name;
5. int age;
6.
7. Player() {
8. this.name = "Yuvraj";
9. this.age = 36;
10. }
11.
12. public String toString() {
13. return name + ", " + age;
14. }
15.
16. public Class getClass() {
17. return super.getClass();
18. }
19. }
20.
21. public class Test {
22. public static void main(String[] args) {
23. System.out.println(new Player());
24. }
25. }
What will be the result of compiling and executing Test class?
1. package com.udayan.ocp;
2.
3. class X {
4. class Y {
5. private void m() {
6. System.out.println("INNER");
7. }
8. }
9.
10. public void invokeInner() {
11. Y obj = new Y(); //Line 9
12. obj.m(); //Line 10
13. }
14. }
15.
16. public class Test {
17. public static void main(String[] args) {
18. new X().invokeInner();
19. }
20. }
© Copyrights Dumpscity 2025. All Rights Reserved
We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the Dumpscity.