class Test {
class Main {
public static void main(String[]
public static void main(String args[]) {
args) {
System.out.println(fun());
for(int i = 0; 1; i++) {
}
System.out.println("Hello")
static int fun() {
;
break;
return 20; Output: 20
}
Output: Compiler Error }
}
}
}
class Test {
public static void main(String[] import javax.swing.*;
args) {
for(int i = 0; true; i++) {
public class SwingExample {
System.out.println("Hello") public static void main(String[] args)
;
break; { JFrame frame = new JFrame("Test
}
}
Output: Hello Frame"); frame.setSize(300, 200);
} JButton button = new JButton("Click Me");
frame.add(button);
class Main {
public static void main(String button.addActionListener(e -> {
args[]) {
System.out.println(fun());
Int value=1;
} System.out.println(value);
int fun() {
return 20; Value++ });
Output: Compiler
}
frame.setVisible(true); }}
} Error
Output: 1
import javax.swing.*; import java.util.*;
public class SwingExample { public class CollectionExample { public static void
public static void main(String[] args) { main(String[] args) {
JFrame frame = new JFrame("Test Frame"); List<String> list = new ArrayList<>();
Output: nothing will
frame.setSize(300, 200); list.add("A");
appear
JButton button = new JButton("Click Me"); list.add("B");
frame.add(button); list.add("C");
frame.setVisible(False); } } list.remove("A");
System.out.println(list);
}}
public class Test { Output: [B, C]
public static void main(String[] args) import java.util.*;
{ String s1 = "abc"; Output: False public class CollectionExample {
String s2 = "abc"; public static void main(String[] args) {
System.out.println(s1 instanceof s2); }} List<Integer> list = new ArrayList<>(Arrays.asList(1, 2, 3,
4, 5));
list.removeIf(x -> x % 3 == 0);
System.out.println(list); } }
Output :[1, 2, 4, 5]