exam questions

Exam 1z0-819 All Questions

View all questions & answers for the 1z0-819 exam

Exam 1z0-819 topic 1 question 44 discussion

Actual exam question from Oracle's 1z0-819
Question #: 44
Topic #: 1
[All 1z0-819 Questions]

Given:

Which two interfaces can be used in lambda expressions? (Choose two.)

  • A. MyInterface4
  • B. MyInterface5
  • C. MyInterface1
  • D. MyInterface3
  • E. MyInterface2
Show Suggested Answer Hide Answer
Suggested Answer: C 🗳️

Comments

Chosen Answer:
This is a voting comment (?). It is better to Upvote an existing comment if you don't have anything to add.
Switch to a voting comment New
06d854e
4 months ago
Thus, the correct answers are MyInterface1 and MyInterface4. Ans A and C
upvoted 1 times
...
c47d39c
5 months, 3 weeks ago
A,C MyInterface3 has 2 abstract methods,MyInterface5 has a compile time error(static methods in an interface must have a body)
upvoted 1 times
...
rami_mlaiel
9 months, 1 week ago
Selected Answer: C
Lambda expressions can only be used with functional interfaces, which are interfaces with a single abstract method (SAM) but can have any other type of functions: A. MyInterface4 (Bad syntax dMethod must have default before return type) B. MyInterface5 (Not valid, has 2 abstract method) C. MyInterface1 (Valid has one abstract method) D. MyInterface3 (Not valid, has 2 abstract method) E. MyInterface2 (Not valid does not have an abstract method) So, the correct answers are: C. MyInterface1 If there was a default in option A. MyInterface4 then it will be correct
upvoted 1 times
ASPushkin
5 months ago
B.MyInterface5 Not valid, static method without implementation
upvoted 1 times
...
...
Bravo6633
10 months, 2 weeks ago
Selected Answer: AD
A and D is the answer.
upvoted 1 times
...
d7bb0b2
1 year ago
B AND C !
upvoted 1 times
d7bb0b2
1 year ago
Correct, only C : A. MyInterface4=> method abstract cannot contain body B. MyInterface5 => static method must be a body C. MyInterface1 => OK D. MyInterface3=> has two abstract methods NOT SAM E. MyInterface2=> no abstract methods, booleans equeals is no count as abstract
upvoted 1 times
...
...
d7bb0b2
1 year, 1 month ago
The answer is A . private and static method in interface must be contain a body
upvoted 2 times
d7bb0b2
1 year ago
A. MyInterface4=> method abstract cannot contain body B. MyInterface5 => OK C. MyInterface1 => OK D. MyInterface3=> has two abstract methods NOT SAM E. MyInterface2=> no abstract methods, booleans equeals is no count as abstract method because is from object class
upvoted 1 times
d7bb0b2
1 year ago
and NOTE: FOR E private methods and static must containt body
upvoted 1 times
d7bb0b2
1 year ago
!and : B is bad sstatic must be body
upvoted 1 times
...
...
...
...
Kee0369
1 year, 1 month ago
Selected Answer: BD
Lambda expressions can only be used with functional interfaces, which are interfaces with a single abstract method (SAM). Let's analyze the provided interfaces: A. MyInterface4 (not provided in the initial interfaces) B. MyInterface5 (valid, as it has a single abstract method) C. MyInterface1 (not provided in the initial interfaces) D. MyInterface3 (valid, as it has a single abstract method) E. MyInterface2 (not valid, as it has more than one abstract method) So, the correct answers are: B. MyInterface5 D. MyInterface3
upvoted 1 times
d7bb0b2
1 year, 1 month ago
MyInterface3 has two abstract methods
upvoted 1 times
...
...
Kee0369
1 year, 1 month ago
Lambda expressions can only be used with functional interfaces, which are interfaces with a single abstract method (SAM). Let's analyze the provided interfaces: A. MyInterface4 (not provided in the initial interfaces) B. MyInterface5 (valid, as it has a single abstract method) C. MyInterface1 (not provided in the initial interfaces) D. MyInterface3 (valid, as it has a single abstract method) E. MyInterface2 (not valid, as it has more than one abstract method) So, the correct answers are: B. MyInterface5 D. MyInterface3
upvoted 1 times
...
[Removed]
1 year, 4 months ago
Selected Answer: C
MyInterface3 CANNOT BE A FUNCTIONAL INTERFACE. A functional interface can only have 1 abstract method. Myinterface2 is incorrect because an abstract method cannot be private. MyInterface4 is incorrect as the compiler will try to insert abstract into the first method which doesn't compile as an abstract method can't have a body. Myinterface5 won't compile since an abstract method can't be static. MyInterface1 is the only correct answer as it has exactly 1 abstract method. An interface can contain private methods.
upvoted 1 times
...
Omnisumem
1 year, 5 months ago
Selected Answer: CD
CORRECT: C and D (interfaces 1 and 3)
upvoted 1 times
...
Omnisumem
1 year, 5 months ago
Selected Answer: AC
Tested: A and C. It compiles in combination, C can not be alone.
upvoted 2 times
...
RoxyFoxy
1 year, 7 months ago
Selected Answer: A
Correct answer: JUST A. @FunctionalInterface //OK public interface MyInterface1 { public int method() throws Exception; private void pMethod(){} } // NO @FunctionalInterface interface MyInterface2 { public static void sMethod() {} private boolean equals(); //is private!! must be abstract| have body } // NO @FunctionalInterface - has two abstract methods interface MyInterface3 { public void method(); public void method(String str); } //@FunctionalInterface: NO interface MyInterface4 { public void dMethod() {}//must be static or default: NOT COMPILE public void Method(); }
upvoted 2 times
RoxyFoxy
1 year, 7 months ago
To see that an interface is a functional interface, add the annotation @FunctionalInterface. Only functional interfaces can be added to lambda expressions. MyInterface2 and MyInterface4 give compilation error, and MyInterface3 has two abstract methods. So only MyInterface1 is correct, I think...
upvoted 3 times
...
...
Stavok
1 year, 7 months ago
Selected Answer: CD
C & D are correct
upvoted 1 times
Stavok
1 year, 6 months ago
C. MyInterface1 can be used in a lambda expression because it has exactly one abstract method, method(), which is the requirement for an interface to be a functional interface. A functional interface is an interface that has exactly one abstract method and can be used as the target type for a lambda expression. D. MyInterface3 can also be used in a lambda expression because it also has exactly one abstract method, method(). The second method, method(String str), is an overloaded version of the first method and does not count as a separate abstract method. The other options are incorrect because they do not meet the requirement of having exactly one abstract method.
upvoted 1 times
...
...
Mukes877
1 year, 7 months ago
Selected Answer: AD
A & D are correct Because In lambda expression Interface should have only one abstract method. There should not be any Static method and private method. So MyInteface3 & MyInterface4 are correct. others are wrong
upvoted 1 times
...
Jtic
1 year, 11 months ago
Selected Answer: CD
D Pass -> Interface abstract methods cannot have body public void method(); public void method(String str); as well as C public int method() throws Exception; private void pMethod() { /* an implementation of pMethod */ }
upvoted 1 times
...
RP384
1 year, 11 months ago
Selected Answer: C
C is correct
upvoted 2 times
...
RP384
1 year, 11 months ago
Only C is correct, in A the static method needs a body
upvoted 1 times
...
Community vote distribution
A (35%)
C (25%)
B (20%)
Other
Most Voted
A voting comment increases the vote count for the chosen answer by one.

Upvoting a comment with a selected answer will also increase the vote count towards that answer by one. So if you see a comment that you already agree with, you can upvote it instead of posting a new comment.

SaveCancel
Loading ...
exam
Someone Bought Contributor Access for:
SY0-701
London, 1 minute ago