What will be the output of the following program? interface I1 { default void m2() { System.out.println("bye"); } void m1(); } @FunctionalInterface interface I2 extends I1 { default void m2() { System.out.println("hello"); } } public class Test { public static void main(String[] args) { I2 x = () -> System.out.println("hi"); x.m1(); x.m2(); } }

Java Programming Quiz

Quiz
•
Other
•
Professional Development
•
Hard
Venubabu Venubabu
Used 1+ times
FREE Resource
60 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
hi bye
Compilation Error
hi hello
Runtime Error
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will the output of the following code? public interface A111 { String s = "yo"; public void method1(); } interface B { } interface C extends A111, B { public void method1(); public void method1(int x); }
Compilation succeeds.
Compilation fails due to multiple errors.
Compilation fails due to an error only on line 20.
Compilation fails due to an error only on line 21.
Compilation fails due to an error only on line 22.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following program? import java.util.function.Predicate; public class Test { public static void main(String[] args) { Predicate
no output
true true
true false
true
true true
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Is there any error in the following code? @FunctionalInterface public interface MyInterface { String myInterface(String a); int hashCode(); String toString(); }
The code will compile.
The code will give a compilation error.
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following program? @FunctionalInterface interface MyInterface { String cal(String value); } public class FunctionalInterfaceExample { public static void main(String[] args) { MyInterface myInterface = (String value) -> 75 + value; System.out.println(myInterface.cal("hi" + 25)); } }
hi7525
hi2527
75hi25
hi100
None of the above
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following program? @FunctionalInterface interface MyInterface { public String nit(String name); } public class FunctionalInterfaceExample { public static void main(String[] args) { MyInterface myInterface = (String name) -> "Welcome to "; System.out.println(myInterface.nit("Learning")); } }
Welcome to Learning
Learning Welcome to
No output
Compile time error
Welcome to
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What will be the output of the following program? @FunctionalInterface interface Movie { String movieName(); } public class TestMcq { public static void main(String[] args) { Movie m = () -> return "DDLJ"; System.out.println(m.movieName()); } }
No output
DDLJ
ddlj
Movie
Compile time error
Create a free account and access millions of resources
Similar Resources on Quizizz
59 questions
Classroom Etiquette Quiz

Quiz
•
Professional Development
60 questions
Soft Skills

Quiz
•
University - Professi...
55 questions
BT - Ch-10 Indentifying and Preventing Fraud

Quiz
•
Professional Development
60 questions
OSI Model and Networking Concepts

Quiz
•
Professional Development
55 questions
VOCABULARY U2 READING

Quiz
•
Professional Development
60 questions
Java Programming Quiz

Quiz
•
Professional Development
55 questions
Assessment 1

Quiz
•
Professional Development
65 questions
Module 7 Vocabulary Terms - File Types and Data Formats

Quiz
•
Professional Development
Popular Resources on Quizizz
15 questions
Multiplication Facts

Quiz
•
4th Grade
20 questions
Math Review - Grade 6

Quiz
•
6th Grade
20 questions
math review

Quiz
•
4th Grade
5 questions
capitalization in sentences

Quiz
•
5th - 8th Grade
10 questions
Juneteenth History and Significance

Interactive video
•
5th - 8th Grade
15 questions
Adding and Subtracting Fractions

Quiz
•
5th Grade
10 questions
R2H Day One Internship Expectation Review Guidelines

Quiz
•
Professional Development
12 questions
Dividing Fractions

Quiz
•
6th Grade