Premium

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



Question : What is the result?`
 : What is the result?`
1. 97 98
99 100 null null null
2. 97 98
99 100 101 102 103
3. Compilation Fails.
4. A NullPointerException is thrown at runtime.
5. An ArraylndexoutofBoundsException is thrown at runtime.


Correct Answer : 1







Question : Given the code fragment:

int x=100;
int a = x++;
int b = ++x;
int c = x++;
int d = (a System.out.println(d);

What is the result?

  : Given the code fragment:
1. 100
2. 101
3. 102
4. 103
5. Compilation Fails





Correct Answer : 5






Question : Given the following main method:

public static void main(String args[]){
int num = 5;
do{
System.out.println(num-- + " ");
}while(num ==0);
}

What is the result ?

 : Given the following main method:
1. 5 4 3 2 1 0
2. 5 4 3 2 1
3. 4 2 1
4. 5
5. Nothing is printed


Correct Answer : 4



Related Questions


Question : Which code fragment, when inserted at line n,
enables the code to print Harish?
  : Which code fragment, when inserted at line n,
1. checkAge (iList, ( ) -> p. get Age () > 40);
2. checkAge(iList, Person p -> p.getAge() > 40);
3. checkAge (iList, p -> p.getAge() > 40);
4. checkAge(iList, (Person p) -> { p.getAge() > 40; });




Question : Given the code snippet :

When you run this code, what will be printed

  : Given the code snippet :
1. X Y Z
2. X Y Z P Q
3. X Y P Q
4. Compilation Error



Question : Please look into , given code fragement.
Select the correct options which will be printed out.

  : Please look into , given code fragement.
1. true true
2. true false
3. false false
4. false true




Question : Please look into given code fragement.
Which of the following conditional statement will help
you to print Equal ?
  : Please look into given code fragement.
1. String firstString = secondString;
if(firstString==secondString)
2. if(firstString.equlaIgnoreCase(secondString))
3. String thirdString = secondString;
if(firstString.equals(thirdString));
4. if(firstString.toLowerCase() == str2.toLowerCase())




Question : You have been given below code fragement

StringBuilder sb = new StringBuilder ( ) ;
sb.append ("world");

Which code fragment prints Hello World?

  :   You have been given below code fragement
1. sb.insert(0,"Hello "); System.out.println(sb);
2. sb.append(0,"Hello "); System.out.println(sb);
1. sb.add(0,"Hello "); System.out.println(sb);
2. sb.set(0,"Hello "); System.out.println(sb);





Question : Given the code fragment:
String h1 = "Bob";
String h2 = new String ("Bob");
What is the best way to test that the values of h1 and h2 are the same?

  : Given the code fragment:
1. if (h1 = = h2)
2. if (h1.equals(h2))
3. if (h1 = = h2)
4. if (h1.same(h2))