Java MCQs - 15
Consider the following code: public class Main { public static void main(String[] args) { Strin...
Consider the following code: public class Main { public static void main(String[] args) { Strin...
Consider the following code: public class Main { public static void main(String[] args) { int[]...
Consider the following code: class A { int x = 5; void display() { System.out.pri...
What is the output of the following code? System.out.println("Java".endsWith("va")); A) true B) false C) Compiler ...
What is the output of the following code? String str = "Hello,World"; System.out.println(str.split(",")[1]); A) Hell...
What is the output of the following code? System.out.println("Java".substring(1, 3)); A) Jav B) av C) ava D) Compiler error...
What is the output of the following code? String str = "Java"; str.concat(" Programming"); System.out.println(str); ...
What does the this keyword refer to in Java? A) It refers to the previous object. B) It refers to the next object. C) It refers to the curre...
What is the output of the following code? String str = "Hello, World!"; System.out.println(str.indexOf("o")); A) 5...
What is the output of the following code? int[][] arr = {{1, 2, 3}, {4, 5, 6}, {7, 8, 9}}; System.out.println(arr[1][2]); A)...
What is the output of the following code? String str = "Hello, World!"; System.out.println(str.substring(7)); A) World! B...
What is the output of the following code? int x = 5; int y = 2; System.out.println(x / y); A) 2.5 B) 2 C) 2.0 D) 2.5 wit...
Which keyword is used to specify that a method does not return any value in Java? A) void B) null C) none D) empty Answer: A) void ...
Which of the following is true about Java? A) Java is a low-level programming language. B) Java is a purely procedural language. C) Java i...
In Java, applets are programs that are run within a web browser, and they can use the Graphics class to draw graphics and images within the applet....
In Java, the ActionListener interface is used to detect and respond to events related to a component, such as a button click or menu item selection....
In Java, listeners are used to detect and respond to events such as button clicks, mouse movements, or keyboard input....
In Java applets, event handling is used to respond to user actions, such as clicking a button or selecting an item from a menu. ...
Java applets are small applications that are executed within a web browser using a Java Virtual Machine (JVM). They were commonly used in the early days of the web to add interactive and multimedia content to web pages....
We are providing common Java interview questions and answers that may help you prepare for a job interview...