Premium

Oracle Advacned Java Advanced Certification Questions and Answers (Dumps and Practice Questions)



Question : Which of the following is a correct override for extending the ListResourceBundle class?


 : Which of the following is a correct override for extending the ListResourceBundle class?
1. public HashMap getContents() {
Map contents = new HashMap<>();
contents.add("Hadoop", "Exam");
return contents;
}

2. public Object[] getContents() {
return new Object[] { { "Hadoop" } , { "Exam" } };
}

3. public Object[][] getContents() {
return new Object[][] { { "Hadoop", "Exam" } };
}

4. public String[] getKeysAndValues() {
return new String[] { { "Hadoop" } , { "Exam" } };
}


Correct Answer : 3
Explanation: The return type of the getContents() method is Object[][]. Further, the method should return a new
object of type Object [][] from the method body.





Question : You have been given below code, what is the behavior expectd?

package com.hadoopexam;

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.temporal.ChronoUnit;

public class Welcome {

public static void main(String[] args) {
ZonedDateTime startTime = ZonedDateTime.of(2016, 1, 01, 2, 0, 0, 0, ZoneId.of("UTC-4"));
ZonedDateTime endTime = ZonedDateTime.of(2016, 1, 01, 8, 0, 0, 0, ZoneId.of("UTC-1"));
long hrs = ChronoUnit.HOURS.between(startTime, endTime); // line n1
System.out.println("Total time difference is " + hrs + " hours");
}
}


 : You have been given below code, what is the behavior expectd?
1. Total time difference is 4 hours

2. Total time difference is 3 hours

3. Total time difference is 2 hours

4. An exception is thrown at line n1.


Correct Answer : 2
Explanation: ZonedDateTime.of(2016, 1, 01, 2, 0, 0, 0, ZoneId.of("UTC-4")); -> UTC Time = 2+4 = 6
ZonedDateTime.of(2016, 1, 01, 8, 0, 0, 0, ZoneId.of("UTC-1") -> UTC Time = 8+1 =9

9-6=3





Question : Assume that you've the following resource bundles in your classpath:
ResourceBundle.properties
ResourceBundle_ar.properties
ResourceBundle_en.properties
ResourceBundle_it.properties
ResourceBundle_it_IT_Rome.properties
Also assume that the default locale is English (US), where the language code is en and
country code is US. Which one of these five bundles will be loaded for the call
loadResourceBundle("ResourceBundle", new Locale("fr", "CA", ""));?


 : Assume that you've the following resource bundles in your classpath:
1. ResourceBundle.properties

2. ResourceBundle_ar.properties

3. ResourceBundle_en.properties

4. ResourceBundle_it.properties

5. ResourceBundle_it_IT_Rome.properties


Correct Answer : 3
Explanation: Java looks for candidate locales for a base bundle named ResourceBundle and locale
French (Canada), and checks for the presence of the following property files:
ResourceBundle_fr_CA.properties
ResourceBundle_fr.properties
Since both of them are not there, Java searches for candidate locales for the base
bundle named ResourceBundle and a default locale (English - United States):
ResourceBundle_en_US.properties
ResourceBundle_en.properties
Java finds that there is a matching resource bundle,
ResourceBundle_en.properties. Hence it loads this resource bundle



Related Questions


Question : You have been given below code, what is the expected result ?

package com.hadoopexam;

import java.nio.file.Path;
import java.nio.file.Paths;

public class Welcome {

public static void main(String[] args) {
Path path1 = Paths.get("/my/./file/");
Path res1 = path1.resolve("file.txt");
Path path2 = Paths.get("/data/use/");
Path res2 = path2.resolve("/hadoop.txt/");
System.out.println(res1);
System.out.println(res2);
}
}


 : You have been given below code, what is the expected result ?
1. \my\.\file\file.txt
\data\use\hadoop.txt

2. \my\.\file\file.txt
\hadoop.txt

3. It will throw error : java.nio.file.InvalidPathException: UNC path is missing sharename:
4. java.nio.file.InvalidPathException: UNC path is missing sharename: //hadoop.txt/



Question : Which of the following can be a valid syntax for , resource bundle property files ?





 : Which of the following can be a valid syntax for , resource bundle property files ?
1. Key:value

2. Key=value

3. Key==value

4. Key;value





Question : You have been given below code, what is the behavior expected?

package com.hadoopexam;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

public class Welcome {

public static void main(String[] args) {
List allSites = Arrays.asList("HadoopExam", "QuickTechie", "Training4Exam");
Predicate predicate = site -> {
System.out.println("Watching Hadoop Training Course ...");
return site.contains("Hadoop");
};
allSites.stream().filter(siteName -> siteName.length() > 3).allMatch(predicate);
}
}



 : You have been given below code, what is the behavior expected?
1. It will print Watching Hadoop Training Course ...

2. It will print
Watching Hadoop Training Course ...
Watching Hadoop Training Course ...

3. It will print
Watching Hadoop Training Course ...
Watching Hadoop Training Course ...
Watching Hadoop Training Course ...

4. There will be a compile time error.



Question : You have been given below code, what is the expected behavior?

package com.hadoopexam;

import java.util.Locale;

class Welcome {
public static void main(String[] args) {
Locale locale = new Locale("quick", "Hadoop");
System.out.println(locale);
}
}



 : You have been given below code, what is the expected behavior?
1. It will give compile time error.

2. It will give runtime error.

3. It will compile and run but no output.

4. It will give NullPointer Exception at run time

5. It will produce output as "quick_HADOOP"



Question : You have been given below code, what is the behavior expected?
package com.hadoopexam;
class ParentException extends Exception {}

class ChildException extends ParentException {}

public class Welcome {
public void subscribeForCourse(String courseName, int fee) throws ParentException, ChildException {
if (courseName.length() < 6) {
throw new ParentException();
} else if (fee >= 60) {
throw new ChildException();
} else {
System.out.println("You are allowed for this course");
}
}

public static void main(String[] args) throws ParentException {
Welcome t = new Welcome();
t.subscribeForCourse("Hadoop", 60);
}
}

 : You have been given below code, what is the behavior expected?
1. It will print : You are allowed for this course

2. It will print : Hadoop

3. It will throw Exception in thread "main" com.hadoopexam.ChildException

4. It will give compile time error.

5. It will throw Exception in thread "main" com.hadoopexam.ParentException



Question : You have been given below code, what is the expected behavior when executed?

package com.hadoopexam;

import java.util.Locale;

class Welcome {
public static void main(String[] args) {
Locale l1 = new Locale("en");
Locale l2 = new Locale("en", "in");
Locale l3 = new Locale("th", "TH", "TH");
Locale l4 = new Locale(l3);
System.out.println(l1 + " " + l2 + " " + l3 + " " + l4);
}
}
 : You have been given below code, what is the expected behavior when executed?
1. It will give compile time error.

2. It will give run time error.

3. It will compile and run with output as "en en_IN th_TH_TH_#u-nu-thai th_TH_TH_#u-nu-thai"

4. It will compile and run with output as "en en_IN th_TH_TH_#u-nu-thai th_TH_TH_#u-nu-IN"