Which of the following statements is/are TRUE regarding JAVA ?(a) Constants that cannot be changed are declared using the ‘static’ keyword.(b) A class can only inherit one class but can implement multiple interfaces.- Only (a) is TRUE
- Only (b) is TRUE.
- Both (a) and (b)are TRUE
- Neither (a) nor (b) is TRUE
Answer (Detailed Solution Below)Option 2 : Only
(b) is TRUE. Free Teaching Aptitude Mock Test 10 Questions 20 Marks 12 Mins The correct answer is option 2. Statement a: FALSE In Java, to declare any variable as constant, static and final modifiers are used Statement b: TRUE In JAVA, A class can implement
multiple interfaces but the class can inherit only one class To inherit class, extends is used and to inherit an interface, implements keyword is used Hence the correct answer is Only (b) is TRUE. Last updated on Nov 4, 2022 UGC NET Results and Cut-Off is to
be released on 5th November 2022. The final provisional answer key for all phases of UGC NET Merged Cycle (December 2021 and June 2022) was released on 2nd November 2022. Earlier, the provisional answer key was released and candidates could submit objections against the same till 26th October 2022. The UGC NET CBT exam consists of two papers - Paper I and Paper II. Paper I will be conducted of 50 questions and Paper II
will be held for 100 questions. By qualifying this exam candidates are deemed eligible for JRF and Assistant Professor posts in Universities and Institutes across the country. next → ← prev An Interface that contains exactly one abstract method is known as functional interface. It can have any number of default, static methods but can contain only one abstract method. It can also declare methods of object class. Functional Interface is also known as Single
Abstract Method Interfaces or SAM Interfaces. It is a new feature in Java, which helps to achieve functional programming approach.
Example 1 Test it NowOutput: Hello there
A functional interface can have methods of object class. See in the following example. Example 2
Test it NowOutput: Hello there
Invalid Functional InterfaceA functional interface can extends another interface only when it does not have any abstract method. Output: compile-time error
Example 3In the following example, a functional interface is extending to a non-functional interface.
Test it NowOutput: Hello there
Do it now
Java Predefined-Functional InterfacesJava provides predefined functional interfaces to deal with functional programming by using lambda and method references. You can also define your own custom functional interface. Following is the list of functional interface which are placed in java.util.function
package.
Interface | Description |
---|
BiConsumer<T,U>
| It represents an operation that accepts two input arguments and returns no result.
| Consumer<T>
| It represents an operation that accepts a single argument and returns no result.
| Function<T,R>
| It represents a function that accepts one argument and returns a result.
| Predicate<T>
| It represents a predicate (boolean-valued function) of one argument.
| BiFunction<T,U,R>
| It represents a function that accepts two arguments and returns a a result.
| BinaryOperator<T>
| It represents an operation upon two operands of the same data type. It returns a result of the same type as the operands.
| BiPredicate<T,U>
| It represents a predicate (boolean-valued function) of two arguments.
| BooleanSupplier
| It represents a supplier of boolean-valued results.
| DoubleBinaryOperator
| It represents an operation upon two double type operands and returns a double type value.
| DoubleConsumer
| It represents an operation that accepts a single double type argument and returns no result.
| DoubleFunction<R>
| It represents a function that accepts a double type argument and produces a result.
| DoublePredicate
| It represents a predicate (boolean-valued function) of one double type argument.
| DoubleSupplier
| It represents a supplier of double type results.
| DoubleToIntFunction
| It represents a function that accepts a double type argument and produces an int type result.
| DoubleToLongFunction
| It represents a function that accepts a double type argument and produces a long type result.
| DoubleUnaryOperator
| It represents an operation on a single double type operand that produces a double type result.
| IntBinaryOperator
| It represents an operation upon two int type operands and returns an int type result.
| IntConsumer
| It represents an operation that accepts a single integer argument and returns no result.
| IntFunction<R>
| It represents a function that accepts an integer argument and returns a result.
| IntPredicate
| It represents a predicate (boolean-valued function) of one integer argument.
| IntSupplier
| It represents a supplier of integer type.
| IntToDoubleFunction
| It represents a function that accepts an integer argument and returns a double.
| IntToLongFunction
| It represents a function that accepts an integer argument and returns a long.
| IntUnaryOperator
| It represents an operation on a single integer operand that produces an integer result.
| LongBinaryOperator
| It represents an operation upon two long type operands and returns a long type result.
| LongConsumer
| It represents an operation that accepts a single long type argument and returns no result.
| LongFunction<R>
| It represents a function that accepts a long type argument and returns a result.
| LongPredicate
| It represents a predicate (boolean-valued function) of one long type argument.
| LongSupplier
| It represents a supplier of long type results.
| LongToDoubleFunction
| It represents a function that accepts a long type argument and returns a result of double type.
| LongToIntFunction
| It represents a function that accepts a long type argument and returns an integer result.
| LongUnaryOperator
| It represents an operation on a single long type operand that returns a long type result.
| ObjDoubleConsumer<T>
| It represents an operation that accepts an object and a double argument, and returns no result.
| ObjIntConsumer<T>
| It represents an operation that accepts an object and an integer argument. It does not return result.
| ObjLongConsumer<T>
| It represents an operation that accepts an object and a long argument, it returns no result.
| Supplier<T>
| It represents a supplier of results.
| ToDoubleBiFunction<T,U>
| It represents a function that accepts two arguments and produces a double type result.
| ToDoubleFunction<T>
| It represents a function that returns a double type result.
| ToIntBiFunction<T,U>
| It represents a function that accepts two arguments and returns an integer.
| ToIntFunction<T>
| It represents a function that returns an integer.
| ToLongBiFunction<T,U>
| It represents a function that accepts two arguments and returns a result of long type.
| ToLongFunction<T>
| It represents a function that returns a result of long type.
| UnaryOperator<T>
| It represents an operation on a single operand that returnsa a result of the same type as its operand.
|
Next TopicJava 8 Stream ← prev next →
Which of the following statement is true about interfaces?
Answer and Explanation: 1. The only true statement is C), All methods defined in an interface must be implemented when used by another class.
Which of the following is true about interface in Java?
Which of the following is true about interfaces in Java? An interface can contain following type of members. public, static, final fields(i.e., constants) default and static methods with bodies.
Which of the following statement is false about interfaces in Java?
Q) False statement about Java interface
It can be instantiated, means, we can create an object of an interface. There can be only abstract methods in the interface not method body. All are correct.
Which of the following statements is correct about interfaces used in c# net?
Which of the following statements is correct about an interface used in C#.NET? One class can implement only one interface. In a program if one class implements an interface then no other class in the same program can implement this interface. From two base interfaces a new interface cannot be inherited.
|