1. package com.sampleproject.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. /*INSERT*/ x = 7, y = 200;
6. System.out.println(String.valueOf(x + y).length());
7. }
8. }
Which of the following options, if used to replace /*INSERT*/, will compile successfully and on execution will print 3 on to the console?
Select 3 options.
1. public class Thought {
2. /*INSERT*/ {
3. System.out.println("All is well");
4. }
5. }
Which 3 options, if used to replace /*INSERT*/, will compile successfully and on execution will print "All is well" on to the console?
1. package com.sampleproject.oca;
2.
3. interface Blogger {
4. default void blog() throws Exception {
5. System.out.println("GENERIC");
6. }
7. }
8.
9. class TravelBlogger implements Blogger {
10. public void blog() {
11. System.out.println("TRAVEL");
12. }
13. }
14.
15. public class Test {
16. public static void main(String[] args) {
17. Blogger blogger = new TravelBlogger(); //Line n1
18. ((TravelBlogger)blogger).blog(); //Line n2
19. }
20. }
What will be the result of compiling and executing Test class?
package com.udayan.oca;
public class Test {
public static void main(String[] args) {
m1(null);
}
static void m1(CharSequence s) {
System.out.println("CharSequence");
}
static void m1(String s) {
System.out.println("String");
}
static void m1(Object s) {
System.out.println("Object");
}
}
© 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.