Premium

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



Question : You have been given below code, what is the expected behavior. All are in same package?

class Parent {
public final void call(int min, int temp) {
}

public void mix() {
}
}
public final class Peer {
public void peerMethod() {
}
}

public class Peer2 {
private Parent c = new Parent();
private final double discount = 0.25;

public void peer2Call() {
c.call(10, 120);
}
}

public class Child1 extends Parent {
public void call(int minutes, int temperature) {}
public void childMethod() {
}
}

 : You have been given below code, what is the expected behavior. All are in same package?
1. A compilation error occurs in Parent.

2. A compilation error occurs in Peer.

3. Access Mostly Uused Products by 50000+ Subscribers

4. A compilation error occurs in Child1

5. All classes compile successfully.


Correct Answer : Get Lastest Questions and Answer :
Explanation: : The final keyword can be applied for classes, methods, and variables. You cannot extend a final class,
you cannot override a final method, and you cannot change the value of a final variable once it is initialized.





Question : Which two statements are true about localizing an application?
A. Support for new regional languages does not require recompilation of the code.
B. Textual elements (messages and GUI labels) are hard-coded in the code.
C. Language and region-specific programs are created using localized data.
D. Resource bundle files include data and currency information.
E. Language codes use lowercase letters and region codes use uppercase letters.

 : Which two statements are true about localizing an application?
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. D,E
5. A,E

Correct Answer : Get Lastest Questions and Answer :
Explanation: A locale represents a language, culture, or country; the Locale class in Java provides an abstraction for this concept.
. Each locale can have three entries: the language, country, and variant. You can use standard codes available for language and country to form locale tags.
There are no standard tags for variants; you can provide variant strings based on your need.
. The getter methods in the Locale class-such as getLanguage(), getCountry(), and getVariant()-return codes; whereas the similar methods of getDisplayCountry(),
getDisplayLanguage(), and getDisplayVariant() return names.
. The getDefault() method in Locale returns the default locale set in the JVM. You can change this default locale to another locale by using the setDefault() method.
. There are many ways to create or get a Locale object corresponding to a locale:
. Use the constructor of the Locale class.
. Use the forLanguageTag(String languageTag) method in the Locale class.
. Build a Locale object by instantiating Locale.Builder and then call dsetLanguageTag() from that object.
. Use the predefined static final constants for locales in the Locale class.





Question : Which statement is true about java.util.stream.Stream?


 : Which statement is true about java.util.stream.Stream?
1. A stream cannot be consumed more than once.

2. The execution mode of streams can be changed during processing.

3. Access Mostly Uused Products by 50000+ Subscribers

4. A parallel stream is always faster than an equivalent sequential stream


Correct Answer : Get Lastest Questions and Answer :
Explanation: The call to parallel() method changes the execution mode
to parallel stream. It is possible to change the execution mode of a stream after it is created,
and it does not result in throwing any exceptions.



Related Questions


Question : You have been given below code, what is the expected behavior?
package com.hadoopexam;

import java.util.Arrays;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

class Welcome {

public enum Courses {
HADOOP, SPARK, JAVA
}

String name;
Courses course;

public Welcome(String na, Courses cs) {
name = na;
course = cs;
}

public String getName() {
return name;
}

public Courses getCourses() {
return course;
}

public static void main(String[] args) {
List couList = Arrays.asList (
new Welcome ("Jayesh", Welcome.Courses.HADOOP),
new Welcome ("Imtiaz", Welcome.Courses.HADOOP),
new Welcome ("Gautam", Welcome.Courses.SPARK));
Map> userMap = couList.stream ()
.collect(Collectors.groupingBy (Welcome ::getCourses,Collectors.mapping(Welcome::getName, Collectors.toList())));
System.out.println(userMap);
}
}

 : You have been given below code, what is the expected behavior?
1. Compilation error

2. It will print {SPARK=[Gautam], HADOOP=[Jayesh, Imtiaz]}

3. It will print {Gautam =[ SPARK], Jayesh=[ HADOOP, HADOOP]}

4. It will print {Gautam =[ SPARK], Jayesh=[ HADOOP], Imtiaz=[HADOOP]}



Question : You have been given below code, what will be the behavior of the code ?
package com.hadoopexam;

public class Welcome {
CompanyName companyName;

enum CompanyName {
HADOOPEXAM, QUICKTECHIE, TRAINING4EXAM
};

public Welcome(CompanyName pType) {
companyName = pType;
}

public static void main(String[] args) {
CompanyName cName = new CompanyName();
Welcome wel = new Welcome(CompanyName.HADOOPEXAM);
}
}
 : You have been given below code, what will be the behavior of the code ?
1. It will compile and run perfectly

2. It will compile but will run with Error

3. It will run perfectly and print the HADOOPEXAM

4. It will give compile time error.



Question : You have been given below code, what behavior you are expecting.

package com.hadoopexam;

public enum Welcome {

private int totalProducts; // n1
HadoopExam(30), QuickTechie(5), Training4Exam(50); // n2

private Welcome(int totalProducts) {
this.totalProducts = totalProducts;
}

public int getTotalProducts() {
return totalProducts;
}
}
 : You have been given below code, what behavior you are expecting.
1. It will compile successfully

2. It will compile, but can not run successfully.

3. This is enum definition is not correct, it will through compile time errors.'

4. It will compile and run successfully.



Question : You have been given below code, what will be printed once executed?

package com.hadoopexam;

import java.util.Map;
import java.util.TreeMap;

class Welcome {

public static void main(String[] args) {
Map user = new TreeMap<>();
user.put (1007, "Akash");
user.put (1002, "Kamlesh");
user.put (1001, "Bilash");
user.put (1003, "Bimal");
System.out.println (user);
}
}
 : You have been given below code, what will be printed once executed?
1. {1001=Bimal, 1002=Kamlesh, 1003=Bimal, 1007=Akash}

2. {1007=Akash, 1001=Bimal, 1003=Bimal, 1002=Kamlesh }

3. {1001=Bimal, 1002=Kamlesh, 1007=Akash}

4. {1007=Akash, 1001=Bimal, 1002=Kamlesh }

5. TreeMap is always sorted by Keys. Map can not have duplicate keys, but it can have duplicate values.


java.util.TreeMap.TreeMap()

Constructs a new, empty tree map, using the natural ordering of its keys. All keys inserted into the map must implement the Comparable interface. Furthermore, all such keys
must be mutually comparable: k1.compareTo(k2) must not throw a ClassCastException for any keys k1 and k2 in the map. If the user attempts to put a key into the map that
violates this constraint (for example, the user attempts to put a string key into a map whose keys are integers), the put(Object key, Object value) call
will throw a ClassCastException.



Question : You have been given below code, what behavior are you expecting?

package com.hadoopexam;

interface ParentInterface {
default void call() {
System.out.println("Why are you not working?");
}
}

@FunctionalInterface
interface ChildInterface extends ParentInterface {
@Override
abstract void call();
}

class Welcome {
public static void main(String[] args) {
ChildInterface cInterface = () -> System.out.println("Welcome to HadoopExam Learning Resources");
cInterface.call();
}
}
 : You have been given below code, what behavior are you expecting?
1. There will be a compile time error, as child interface can not override parent interface abstract method.

2. It will given compile time error, because ChildInterface is not a correctr functional interface.

3. This program compile and run perfectly and prints Why are you not working?.

4. This program compile and run perfectly and prints Welcome to HadoopExam Learning Resources.




Question : You have been given below code, what is the behavior you are expecting?

package com.hadoopexam;


class Welcome {

int id;
String name;

public Welcome(int id, String name) {
this.id = id;
this.name = name;
}

public boolean equals(Object obj) { // line n1
boolean output = false;
Welcome b = (Welcome) obj;
if (this.name.equals(b.name))
output = true;
return output;
}

public static void main(String[] args) {
Welcome wel1 = new Welcome(9199, "Hadoop User");
Welcome wel2 = new Welcome(2099, "Hadoop User");
System.out.println(wel1.equals(wel2)); // line n2
}

}


 : You have been given below code, what is the behavior you are expecting?
1. It will compile time error, as you have not overridden the hashCode() method.

2. It will give compile time error, you have to replace System.out.println(wel1.equals((Object)wel2));

3. It will compile and run, and print true

4. It will compile and run and print false.