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(); } } 1. Change line n2 with public void message() throws ParentException
2. Change line n1 with public void message() throws ParentException
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?
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 + " ")); } }
@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 super Welcome> 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 super Welcome, ? extends String> 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
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.