The last statement inside main(String []) method, increments value of i, which means it is not effectively final and hence compilation error.
//Test.java
package com.udayan.ocp;
class Player {
String name;
int age;
Player() {
this.name = "Virat";
this.age = 29;
}
public int hashCode() {
return 100;
}
}
public class Test {
public static void main(String[] args) {
System.out.println(new Player());
}
}
Hexadecimal representation of 100 is 64.
Which of the following option is correct?
What will be the result of compiling and executing class M?
1. package com.udayan.ocp;
2.
3. class M {
4. private int num1 = 100;
5. class N {
6. private int num2 = 200;
7. }
8.
9. public static void main(String[] args) {
10. M outer = new M();
11. M.N inner = outer.new N();
12. System.out.println(outer.num1 + inner.num2);
13. }
14. }
Below is the code of Test.java file:
1. package com.udayan.ocp;
2.
3. class Outer {
4. static class Inner {
5. static void greetings(String s) {
6. System.out.println(s);
7. }
8. }
9. }
10.
11. public class Test {
12. public static void main(String[] args) {
13. /*INSERT*/
14. }
15. }
Which of the following 2 options can replace /*INSERT*/ such that there on executing class Test, output is: HELLO!?
Given code of Test.java file:
1. package com.udayan.ocp;
2.
3. import java.util.ArrayDeque;
4. import java.util.Deque;
5.
6. public class Test {
7. public static void main(String[] args) {
8. Deque
9. deque.push(new Boolean("abc"));
10. deque.push(new Boolean("tRuE"));
11. deque.push(new Boolean("FALSE"));
12. deque.push(true);
13. System.out.println(deque.pop() + ":" + deque.peek() + ":" + deque.size());
14. }
15. }
What will be the result of compiling and executing Test class?
© Copyrights Oracledumps 2025. All Rights Reserved
We use cookies to ensure that we give you the best experience on our website (Oracledumps). If you continue without changing your settings, we'll assume that you are happy to receive all cookies on the Oracledumps.