Correct Answer : Get Lastest Questions and Answer : Explanation: In this code, we are filtering the all the string which contains 1. And then we sort the output.
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); } 1. Welcome wel = Welcome ("Welcome to HadoopExam.com"):: new;
2. Welcome wel = Welcome :: new; Welcome wel1 = wel :: get("Welcome to HadoopExam.com");
1. It will compile and run perfectly and product output as "Value of counter is 10"
2. It will compile and run perfectly and product output as "Value of counter is 0"
3. Code will not compile as no valid Welcome(int) method is defined.
4. Code will not compile because, you are trying to restrict the visibility of toString() method.
5. As we know, every class by default extends the Object class. Which has public toString() method. Hence, you cannot restrict the access modifiers for the overridden method.