Become Oracle Certified with updated 1Z0-808 exam questions and correct answers
What will be the result of compiling and executing Test class?
package com.udayan.oca;
public class Test {
public static void main(String[] args) {
String str = "Java Rocks!";
System.out.println(str.length() + " : " + str.charAt(10));
}
}
Given code of Test.java file:
1. package com.sampleproject.oca;
2.
3. abstract class Animal {
4. abstract void jump() throws RuntimeException;
5. }
6.
7. class Deer extends Animal {
8. void jump() { //Line n1
9. System.out.println("DEER JUMPS");
10. }
11.
12. void jump(int i) {
13. System.out.println("DEER JUMPS TO " + i + " FEET");
14. }
15. }
16.
17. public class Test {
18. public static void main(String[] args) {
19. Animal animal = new Deer();
20. ((Deer)animal).jump(); //Line n2
21. ((Deer)animal).jump(5); //Line n3
22. }
23. }
What will be the result of compiling and executing Test class?
What will be the result of compiling and executing Test class?
1. package com.udayan.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. int x = 1;
6. while(checkAndIncrement(x)) {
7. System.out.println(x);
8. }
9. }
10.
11. private static boolean checkAndIncrement(int x) {
12. if(x < 5) {
13. x++;
14. return true;
15. } else {
16. return false;
17. }
18. }
19. }
How many String objects are there in the HEAP memory, when control is at Line 9?
1. package com.udayan.oca;
2.
3. public class Test {
4. public static void main(String[] args) {
5. String s1 = new String("Java"); //Line 3
6. String s2 = "JaVa"; //Line 4
7. String s3 = "JaVa"; //Line 5
8. String s4 = "Java"; //Line 6
9. String s5 = "Java"; //Line 7
10.
11. int i = 1; //Line 9
12.
13. }
14. }
Which statement is true about the switch statement?
© Copyrights DumpsCertify 2025. All Rights Reserved
We use cookies to ensure your best experience. So we hope you are happy to receive all cookies on the DumpsCertify.