What will be the output of the following code snippet? class Animal { void makeSound() { System.out.println(“Animal sound”); } void sleep() { System.out.println(“Animal sleeps”); } } class Dog extends Animal { @Override void makeSound() { System.out.println(“Bark”); } void fetch() { System.out.println(“Dog fetches”); } } public class Main { public static void main(String[] args) { Animal a = new Dog(); a.makeSound(); a.sleep(); } }
How do you initialize a servlet with custom parameters confi…
How do you initialize a servlet with custom parameters configured in web.xml?
What is the difference between offer() and add() in a queue?
What is the difference between offer() and add() in a queue?
What will be the output of the following code snippet? class…
What will be the output of the following code snippet? class Counter { private static int count = 0; public static synchronized void increment() { count++; try { Thread.sleep(100); } catch (InterruptedException e) {} } public static int getCount() { return count; } } public static void main(String[] args) throws InterruptedException { Thread t1 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 5; i++) Counter.increment(); } }); Thread t2 = new Thread(new Runnable() { public void run() { for (int i = 0; i < 5; i++) Counter.increment(); } }); t1.start(); t2.start(); t1.join(); t2.join(); System.out.println("Final count: " + Counter.getCount()); } }
Which of the following result set types supports moving both…
Which of the following result set types supports moving both forward and backward and reflects database changes?
Which of the following is true about the output? import java…
Which of the following is true about the output? import java.util.concurrent.*; class MyTask implements Runnable { private int taskId; public MyTask(int id) { this.taskId = id; } public void run() { System.out.println(“Task ” + taskId + ” executed by ” + Thread.currentThread().getName()); try { Thread.sleep(100); } catch (InterruptedException e) {} } } public class Main { public static void main(String[] args) { ExecutorService executor = Executors.newFixedThreadPool(2); for (int i = 1; i
What will be the output of the following JSP code snippet? W…
What will be the output of the following JSP code snippet? When the page is refreshed multiple times.
What will be the output of the following code? import java….
What will be the output of the following code? import java.util.*; public class Test { public static void main(String[] args) { List list = new ArrayList(Arrays.asList(1, 2, 3, 4, 5)); Iterator iterator = list.iterator(); while (iterator.hasNext()) { int num = iterator.next(); if (num % 2 == 0) { iterator.remove(); } } System.out.println(list); } }
One of the most positive influences a parent can have on t…
One of the most positive influences a parent can have on their child’s eating habits would be:
Diseases that develop during the adult years partially resul…
Diseases that develop during the adult years partially result from: