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/
Correct Answer : 2 Explanation: If you used this kind of path on a Windows machine (a path starting with /) the path would be interpreted as relative to the current drive.
Path java.nio.file.Path.resolve(String other)
Converts a given path string to a Path and resolves it against this Path in exactly the manner specified by the resolve method. For example, suppose that the name separator is "/" and a path represents "foo/bar", then invoking this method with the path string "gus" will result in the Path "foo/bar/gus". Parameters: other the path string to resolve against this path Returns: the resulting path Throws: InvalidPathException - if the path string cannot be converted to a Path. See Also: FileSystem.getPath
Question : 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
Correct Answer : 2 Explanation: In the resource bundle property files, the key values are separated using the = symbol, with each line in the resource file separated by a newline character.
Question : You have been given below code, what is the behavior expected?
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); } }
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.
Correct Answer : 2 Explanation: allMatch will check for the element until it return true or you can say until it find first false. In this code, it will check siteName contains "Hadoop" word in string for "HadoopExam" its true , hence print statement. Next will check for second string "QuickTechie" its false , by that time print statement executed. Hence, allMatch will stop here. So its checking only two times.
boolean java.util.stream.Stream.allMatch(Predicate super String> predicate)
Returns whether all elements of this stream match the provided predicate. May not evaluate the predicate on all elements if not necessary for determining the result. If the stream is empty then true is returned and the predicate is not evaluated. This is a short-circuiting terminal operation. Parameters: predicate a non-interfering, stateless predicate to apply to elements of this stream Returns: true if either all elements of the stream match the provided predicate or the stream is empty, otherwise false @apiNote This method evaluates the universal quantification of the predicate over the elements of the stream (for all x P(x)). If the stream is empty, the quantification is said to be vacuously satisfied and is always true (regardless of P(x)).
4. It will print "Velocity with new speed 1.4kmph"
5. It will give NullPointerException Correct Answer : Exp : It is a Question of mixing Inner classes as well access outer class variable. As we know distance variable is accessible from inner class. While creating constructor of Welcome class , we assigned distance=100. In Inner class we are acceding defined value of timeTravel=60. Hence, value= 100/60 , as we know both are int value hence result would be int value. Which is 1. So it will print Velocity with new speed 1kmph
Question : You have been given below code. Please select the correct options, which applies to this code.
package com.hadoopexam;
class Parent { public void printValue() { System.out.println("It is a Parent Class"); } }
abstract class Child extends Parent { // n1 public static void main(String[] args) { Parent obj = new Parent(); obj.printValue (); // n2 } } 1. You cannot have an abstract class which can extend non abstract class. Hence, it will give compile time error.
2. Parent class printValue() method is not accessible from a child class.
3. Program will compile successfully and also run perfectly with "It is a Parent Class".
4. There will be a RuntimeError. As child class is an abstract class.
2. It will compile perfectly, but give runtime Exception.
3. It will not even compile, because method Welcome(int ) is not available.
4. It will compile and run perfectly with output as Counter Value =0.
5. : As you know, whenever you do constructor chaining i.e. Same class constructor should be called by another constructor. You should have use this(10) instead of Welcome(10). As it is trying to look for Welcome(10) method.