Premium

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



Question : Which of the following modification in code will print "Welcome to HadoopExam Learning Resources"
package com.hadoopexam;
public class ParentException extends Exception {
public static void main(String[] args) throws ParentException, Exception {
Course v = new HadoopCourse();
v.message();
}
}

class Course {
void message() throws ParentException {// line n1
System.out.println("Welcome to HadoopExam Learning Resources");
}
}

class HadoopCourse extends Course {
public void message() throws Exception {// line n2
super.message();
}
}
 : Which of the following modification in code will print
1. Change line n2 with public void message() throws ParentException

2. Change line n1 with public void message() throws ParentException

3. Access Mostly Uused Products by 50000+ Subscribers

4. Change line n2 with private void message() throws Exception {


Correct Answer : Get Lastest Questions and Answer :
Explanation: In overriding, the name of the method, number of arguments, types of arguments, and return type should match exactly.

You can provide only a less restrictive or same-access modifier when overriding a method.

There are many ways to change the throws clause in the overriding method, including the following:
a. Listing more general checked exceptions to throw.
b. Listing more checked exceptions in addition to the given checked exception(s) in the base method.





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.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class Welcome {

private String courseName;
private Integer duration;

Welcome(String courseName, Integer duration) {
this.courseName = courseName;
this.duration = duration;
}

public Integer getDuration() {
return duration;
}

public String getCourseName() {
return courseName;
}

public static void main(String[] args) {
List subscriberList = Arrays.asList(new Welcome("Hadoop", 12),
new Welcome("Spark", 365), new Welcome("Cloud Computing", 180));

Predicate remainingDays = s -> s.getDuration() > 100;// line n1
subscriberList = subscriberList.stream().filter(remainingDays)
.collect(Collectors.toList());
Stream courseName = subscriberList.stream().map(Welcome::getCourseName);// line n2
courseName.forEach(n -> System.out.print(n + " "));
}
}

 : You have been given below code, what is the expected behavior?
1. It will print Spark Cloud Computing

2. It will print Hadoop Spark Cloud Computing

3. Access Mostly Uused Products by 50000+ Subscribers

4. A compilation error occurs at line n2.


Correct Answer : Get Lastest Questions and Answer :
Explanation: java.util.function.Predicate

@FunctionalInterface
Represents a predicate (boolean-valued function) of one argument.
This is a functional interface whose functional method is test(Object).
Parameters:
the type of the input to the predicate

Stream java.util.stream.Stream.filter(Predicate predicate)

Returns a stream consisting of the elements of this stream that match the given predicate.
This is an intermediate operation.
Parameters:
predicate a non-interfering, stateless predicate to apply to each element to determine if it should be included
Returns:
the new stream

Stream java.util.stream.Stream.map(Function mapper)

Returns a stream consisting of the results of applying the given function to the elements of this stream.
This is an intermediate operation.
Parameters:
The element type of the new stream
mapper a non-interfering, stateless function to apply to each element
Returns:
the new stream





Question : As you know, JDBC is a specification. And every vendor who wants to connect using Java needs to implement specification. Which of the below objects needs to be
implemented by vendor like Oracle, IBM ?


A. Object
B. java.sql.Date
C. Statement
D. ResultSet
E. Connection
F. SQLException


 : As you know, JDBC is a specification. And every vendor who wants to connect using Java needs to implement specification. Which of the below objects needs to be
1. A,B,C
2. C,D,E
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,B,E
5. A,C,F

Correct Answer : Get Lastest Questions and Answer :
Explanation: Database vendors support JDBC through the JDBC driver interface or through the
ODBC connection. Each driver must provide implementations of java.sql.Connection,
java.sql.Statement, java.sql.PreparedStatement, java.sql.CallableStatement, and java.sql.Re
sultSet. They must also implement the java.sql.Driver interface for use by the generic
java.sql.DriverManager interface.



Related Questions


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

package com.hadoopexam;


class ParentException extends IndexOutOfBoundsException {
}

class ParentClass {
void call() throws IndexOutOfBoundsException {
throw new IndexOutOfBoundsException();
}
}

class ChildClass extends ParentClass {
public void call() throws ParentException { // n1
throw new ParentException();
}
}

public class Welcome {
public static void main(String[] args) {
try {
ParentClass parentClass = new ChildClass();
parentClass.call();
} catch (Exception e) {
System.out.println(e);
}
}
}

 : You have been given below code, what is the behavior of the code?
1. It will print com.hadoopexam.ParentException

2. It will print IndexOutOfBoundsException

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will print IllegalStateException

5. It will not compile.



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

package com.hadoopexam;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.Future;

public class Welcome implements Runnable {
String str;

public Welcome(String s) {
this.str = s;
}

public void run() {
System.out.println(str.concat(" : Welcome to HadoopExam Learning Resoueces"));
}

public static void main(String[] args) throws InterruptedException,
ExecutionException {
ExecutorService es = Executors.newFixedThreadPool(2);
Future f1 = es.submit(new CourseCreator("Start Creating Course"));
Future f2 = es.submit(new Welcome("Start Watching Course"));
String str1 = (String) f1.get();
String str2 = (String) f2.get();// line n1
System.out.println(str1 + " : " + str2);
}
}

class CourseCreator implements Callable {
String author;

public CourseCreator(String s) {
this.author = s;
}

public String call() throws Exception {
return author.concat(" : by HadoopExam");
}
}

 : You have been given below code, what is the expected behavior?
1. Start Watching Course : Welcome to HadoopExam Learning Resoueces
Start Creating Course : by HadoopExam : null


2. Start Watching Course : Welcome to HadoopExam Learning Resoueces
Start Creating Course : by HadoopExam : Start Watching Course


3. Access Mostly Uused Products by 50000+ Subscribers

4. An Exception thrown at run time



Question : You have been given below code, in their respective file.

public interface IParent {
public abstract void draw();
}

class Parent implements IParent{
public void draw () { }
}

public abstract class Child1 extends Parent { }


public class Child2 extends Parent {
protected void draw (int color) { }
}


public class GrandChild extends Parent implements IParent {
public void resize() {
}
}

Which is the correct statement?

 : You have been given below code, in their respective file.
1. Child1 does not compile.

2. Child2 does not compile.

3. Access Mostly Uused Products by 50000+ Subscribers

4. IParent does not compile.

5. All classes compile successfully.



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.function.Predicate;

public class Welcome {
public static void main(String[] args) {
List str = Arrays.asList("Welcome", "to", "HadoopExam", "Learning", "Resources");
Predicate predicate = s -> {
int counter = 0;
boolean result = s.contains("Hadoop");
System.out.print((counter++) + ":");
return result;
};
str.stream().filter(predicate).findFirst().ifPresent(System.out::print);

}
}

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

2. 0 : 1 : 2 : Hadoop

3. Access Mostly Uused Products by 50000+ Subscribers

4. 0 : 1 : 2 : 3 : 4 :

5. A compilation error occurs.



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

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 subscriberInfo = Arrays.asList("100, Amit, Hadoop : ", "200, Martha, Spark : ", "101, Piyush, Java : ");
subscriberInfo.stream().filter(s -> s.contains("1")).sorted()
.forEach(System.out::print); // line n1
}
}
 : You have bene given code, what is the expected behavior?
1. 101, Piyush, Java : 100, Amit, Hadoop :

2. 100, Amit, Hadoop : 101, Piyush, Java :

3. Access Mostly Uused Products by 50000+ Subscribers

4. 100, Amit, Hadoop : 101, Piyush, Java : 200, Martha, Spark :

5. Compile time error.



Question : You have been given below code, which of the code segment can be replaced at n. Which create an instance of Welcome class?

package com.hadoopexam;

public class Welcome {

private String name;

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

public static void main(String[] args) {
// n1

}
}

interface Hello {
Welcome get(String name);
}
 : You have been given below code, which of the code segment can be replaced at n. Which create an instance of Welcome class?
1. Welcome wel = Welcome ("Welcome to HadoopExam.com"):: new;

2. Welcome wel = Welcome :: new;
Welcome wel1 = wel :: get("Welcome to HadoopExam.com");

3. Access Mostly Uused Products by 50000+ Subscribers
Welcome wel = hello.get("Welcome to HadoopExam.com");

4. Welcome vehicle = Hello :: new :: get("Welcome to HadoopExam.com");