Premium

Oracle Java Programming Certification Questions and Answers (Dumps and Practice Questions)



Question : Given the code fragment:

public class ForTest {
public static void main(String[] args) {
int[] array = { 1, 2, 3 };
for (foo) {
}
}
}

Which three code fragments, when replaced individually for foo, enables the program to compile?

A. int i : array
B. int i = 0; i < 1;
C. ; ;
D. ; i < 1; i++
E. i = 0; i<1;

 : Given the code fragment:
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,D,E
5. B,C,E





Correct Answer : Get Lastest Questions and Answer :







Question : You have been given following code as below.

public class ComputeSum {
public int x;
public int y;
public int sum;

public ComputeSum(int nx, int ny) {
x = nx;
y = ny;
updateSum();
}

public void setX(int nx) {
x = nx;
updateSum();
}

public void setY(int ny) {
x = ny;
updateSum();
}

void updateSum() {
sum = x + y;
}
}


This class needs to protect changes on the "sum" field. Which three members must have the private access modifier to ensure that this invariant is maintained?

A. The x field
B. The y field
C. The sum field
D. The ComputerSum ( ) constructor
E. The setX ( ) method
F. The setY ( ) method

  : You have been given following code as below.
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,D,E
5. C,E,F



Correct Answer : Get Lastest Questions and Answer :






Question : Which two statements are true?
A. An abstract class can implement an interface.
B. An abstract class can be extended by an interface.
C. An interface CANNOT be extended by another interface.
D. An interface can be extended by an abstract class.
E. An abstract class can be extended by a concrete class.
F. An abstract class CANNOT be extended by an abstract class.
 : Which two statements are true?
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. D,F
5. A,E


Correct Answer : Get Lastest Questions and Answer :



Related Questions


Question : Given:

System.out.println("5 + 2 = " + 3 + 4 );
System.out.println("5 + 2 = " + (3 + 4) );

What is the result?

  : Given:
1. 5 + 2 = 34
5 + 2 = 34
2. 5 + 2 + 3 + 4
5 + 2 = 7
3. 7 = 7
7 + 7
4. 5 + 2 = 34
5 + 2 =7





Question : Given the code fragment:
System.out.printIn("Result: " + 2 + 3 + 5);
System.out.printIn("Result: " + 2 + 3 * 5);
What is the result?

 : Given the code fragment:
1. Result: 10 Result: 30
2. Result: 10 Result: 25
3. Result: 235 Result: 215
4. Result: 215 Result: 215

5. Compilation fails




Question : Given:

What is the result?



  : Given:
1. Base
DerivedA
2. Base
DerivedB
3. DerivedB
DerivedB
4. DerivedB
DerivedA
5. A classcast Except ion is thrown at runtime.



Question : Given:

Which statement is true?
  : Given:
1. Both p and s are accessible by obj.
2. only s is accessible by obj.
3. Both r and s are accessible by obj.
4. p, r, and s are accessible by obj.


Question : You are developing a banking module.
You have developed a class
named ccMask that has a maskcc method.

Given the code fragment as shown in image:
  : You are developing a banking module.
1. A,B
2. B,C
3. C,D
4. A,D




Question : Given the following code:


public static void main(String args[]){

String[] planets = {"Mercury" , "Venus", "Earth" , "Mars"};

System.out.println(planets.length);
System.out.println(planets[1].length());
}

What is the output?



  : Given the following code:
1. 4

2. 3

3. 4

4. 4

5. 4