📘 Premium Read: Access my best content on Medium member-only articles — deep dives into Java, Spring Boot, Microservices, backend architecture, interview preparation, career advice, and industry-standard best practices.
🎓 Top 15 Udemy Courses (80-90% Discount): My Udemy Courses - Ramesh Fadatare — All my Udemy courses are real-time and project oriented courses.
▶️ Subscribe to My YouTube Channel (176K+ subscribers): Java Guides on YouTube
▶️ For AI, ChatGPT, Web, Tech, and Generative AI, subscribe to another channel: Ramesh Fadatare on YouTube
Check out Part 1 - Oracle Java Certification Exam Sample Questions - Part 1.The answer to each question has given at end of this post.
1. Which is a valid functional interface?
public interface Useful<E> {
E getStuff();
void putStuff(E e);
}
public interface Useful {
void doStuff();
default void doOtherStuff() {}
}
@FunctionalInterface
public interface Useful{
default void doStuff(){}
}
public interface Useful {
abstract void doStuff();
abstract void doCalc();
}
2. Given:
public abstract class Customer {
private String name;
public Customer(String name) {
this.name = name;
}
public String getName() {
return name;
}
public abstract void buy();
}
3. Given the code fragment:
import java.util.ArrayDeque;
import java.util.Queue;
public class App {
public static void main(String[] args) {
Queue < String > products = new ArrayDeque < String > ();
products.add("p1");
products.add("p2");
products.add("p3");
System.out.print(products.peek());
System.out.print(products.poll());
System.out.println("");
products.forEach(s - > System.out.print(s));
}
}
p1p1
p2p3
p1p2
p1p2p3
p1p2
p3
p1p1
p1p2p3
4. Given the code fragment:
try (Connection con = DriverManager.getConnection(url, uname, pwd)) {
Statement stmt = con.createStatement();
System.out.print(stmt.executeUpdate("INSERT INTO User VALUES (500,'Ramesh')"));
}
5. Given the code fragment:
public class TestFun {
public static void main(String[] args) {
List<Integer> nums = Arrays.asList(1,2,3,4,5);
// Line n1
}
}
nums.peek(n -> n%2 == 0)
.forEach( s -> System.out.print(" "+s));
nums.filter(n -> n%2 == 0)
.forEach( s -> System.out.print(" "+s));
nums.map(n -> n%2 == 0)
.forEach( s -> System.out.print(" "+s));
nums.stream()
.filter(n -> n%2 == 0)
.forEach( s -> System.out.print(" "+s));
Answers
1. B2. B and E
3. A
4. C
5. D
Comments
Post a Comment
Leave Comment