0% found this document useful (0 votes)
7 views2 pages

Java FX Based MCQ

The document contains multiple Java code snippets illustrating various programming concepts, including class definitions, method declarations, and GUI components using Swing. It highlights common compiler errors and outputs from the code, such as 'Compiler Error' and results from list manipulations. Additionally, it demonstrates the use of event listeners and instance checks in Java.

Uploaded by

Ravi Shankar Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views2 pages

Java FX Based MCQ

The document contains multiple Java code snippets illustrating various programming concepts, including class definitions, method declarations, and GUI components using Swing. It highlights common compiler errors and outputs from the code, such as 'Compiler Error' and results from list manipulations. Additionally, it demonstrates the use of event listeners and instance checks in Java.

Uploaded by

Ravi Shankar Jha
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PPTX, PDF, TXT or read online on Scribd
You are on page 1/ 2

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]

You might also like