Premium

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



Question : Given the code fragment:

public static void main(String[] args){
String date = LocalDate.parse("2014-05-04").format(DateTimeFormatter.ISo_DATE_TIME);
System.out.println(date);
}

What is the result?


 :  Given the code fragment:
1. May 04, 2014T00:00:00.000
2. 2014-05-04T00:00: 00. 000
3. 5/4/14T00:00:00.000
4. An exception is thrown at runtime.



Correct Answer : 4






Question : Given the code fragment:

if(aVar++ <10){
System.out.println(aVar + " Hello World!");
}else{
System.out.println(aVar + " Hello Universe!");
}

What is the result if the integer aVar is 9?


  : Given the code fragment:
1. Hello World!
2. Hello Universe!
3. Hello World
4. Compilation fails.



Correct Answer : 1
Explanation:







Question : Given

What is the result?


  : Given
1. 200.0 : 100.0
2. 400.0 : 200.0
3. 400.0 : 100.0
4. Compilation fails.




Correct Answer : 3




Related 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.



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




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.




Question : You have been given below declarations:

public abstract class Animal
public interface Hunter
public class Cat extends Animalimplements Hunter
public class Tiger extends Cat

Which answer fails to compile?

  : You have been given below declarations:
1. ArrayList myList1 = new ArrayList<>();
myList1.add(new Tiger());
2. ArrayList myList2 = new ArrayList<>();
myList2.add(new Cat());
3. Access Mostly Uused Products by 50000+ Subscribers
myList3.add(new Tiger());
4. ArrayList myList4 = new ArrayList<>();
myList4.add(new Cat());
5. ArrayList myList = new ArrayList<>();
myList.add(new Cat());





Question : Which statement is true about Java byte code?
 : Which statement is true about Java byte code?
1. It can run on any platform.
2. It can run on any platform only if it was compiled for that platform.
3. Access Mostly Uused Products by 50000+ Subscribers
4. It can run on any platform that has a Java compiler.
5. It can run on any platform only if that platform has both the Java Runtime Environment and a Java compiler.






Question :

public class MarkList {
int num;

public static void graceMarks(MarkList obj4) {
obj4.num += 10;
}

public static void main(String[] args) {
MarkList obj1 = new MarkList();
MarkList obj2 = obj1;
MarkList obj3 = null;
obj2.num = 60;
graceMarks(obj2);
}
}

How many MarkList instances are created in memory at runtime?

 :
1. 1
2. 2
3. Access Mostly Uused Products by 50000+ Subscribers
4. 4