Premium

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



Question : You have been given following three classes as below.'

A.java

public class A {
public void a(){}
int a;
}

B.java

public class A {
public void a(){}
int a;
}

C.java
import java.io.*;
package p1;

class A {
public void main(String filename) throws IOException {}
}

Which of the follwing statement is true, with regards to above code.

 : You have been given following three classes as below.'
1. Only the A.Java file compiles successfully.
2. Only the B.java file compiles successfully
3. Access Mostly Uused Products by 50000+ Subscribers
4. The A.Java and B.java files compile successfully
5. The B.java and C.java files compile successfully.


Correct Answer : Get Lastest Questions and Answer :





Question : Given the code fragment:
int[] array = {I, 2, 3, 4, 5};

And given the requirements:
1. Process all the elements of the array in the order of entry.
2. Process all the elements of the array in the reverse order of entry.
3. Access Mostly Uused Products by 50000+ Subscribers

Which two statements are true?

A. Requirements 1, 2, and 3 can be implemented by using the enhanced for loop.
B. Requirements 1, 2, and 3 can be implemented by using the standard for loop.
C. Requirements 2 and 3 CANNOT be implemented by using the standard for loop.
D. Requirement 1 can be implemented by using the enhanced for loop.
E. Requirement 3 CANNOT be implemented by using either the enhanced for loop or the standard for loop.

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



Correct Answer : Get Lastest Questions and Answer :







Question : You have been given below java Application code, when you execute it. What would be printed.

public class CalculationApp {
public static void main(String[] args) {
int var1 =200;
System.out.print(doCalc(var1));
System.out.println(" "+ var1);
}

static int doCalc(int var1){
var1= var1*2;
return var1;

}
}

 : You have been given below java Application code, when you execute it. What would be printed.
1. 400 200
2. 200 200
3. Access Mostly Uused Products by 50000+ Subscribers
4. Compilation fails.



Correct Answer : Get Lastest Questions and Answer :



Related Questions


Question : You have been given following code

public class MyFor {
public static void main(String[] args) {
for (int ii = 0; ii < 4; ii++) {
System.out.println("ii = " + ii);
ii = ii + 1;
}
}
}

What is the result?

 : You have been given following code
1. ii = 0 ii = 2
2. ii = 0 ii = 1ii = 2 ii = 3
3. Access Mostly Uused Products by 50000+ Subscribers

4. Compilation fails.




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. Access Mostly Uused Products by 50000+ Subscribers
4. Result: 215 Result: 215

5. Compilation fails




Question : You have been given following code

public class Student {
public String name = "";
public int age = 0;
public String major = "Undeclared";
public boolean fulltime = true;

public void display() {
System.out.println("Name: " + name + " Major: " + major);
}

public boolean isFullTime() {
return fulltime;
}
}


public class TestStudent {
public static void main(String[] args) {
Student bob = new Student();
bob.name = "Bob";
bob.age = 18;
bob.year = 1982;
}
}

What is the result?

 : You have been given following code
1. year is set to 1982.
2. bob.year is set to 1982
3. Access Mostly Uused Products by 50000+ Subscribers
4. A compile time error is generated.




Question : You have been given following code

public class MyClass {
public static void main(String[] args) {
while(int ii = 0; ii < 2) {
ii++;
System.out.println("ii = " + ii);
}
}
}

What would be result ?


 : You have been given following code
1. ii = 1 ii = 2
2. Compilation fails
3. Access Mostly Uused Products by 50000+ Subscribers
4. The program goes into an infinite loop with no output
5. The program goes to an infinite loop outputting: ii = 1 ii = 1




Question : You have been given following

class Base {
public static void main(String[] args) {
System.out.println("Base " + args[2]);
}
}

public class Sub extends Base {
public static void main(String[] args) {
System.out.println("Overriden " + args[1]);
}
}

 : You have been given following
1. Base 30
2. Overridden 20
3. Access Mostly Uused Products by 50000+ Subscribers
4. Base 30 Overridden 20




Question : You have been given following code

public class ScopeTest {
int j;
int k;

public static void main(String[] args) {
new ScopeTest().doStuff();
}

void doStuff() {
int x = 5;
doStuff2();
System.out.println("x");
}

void doStuff2() {
int y = 7;
System.out.println("y");
for (int z = 0; z < 5; z++) {
System.out.println("z");
System.out.println("y");
}
}
}

Which two items are fields?

A. j
B. k
C. x
D. y
E. z


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