Java Programming

Java is a high-level, object-oriented programming language developed by Sun Microsystems in the mid-1990s. It adheres to the “Write Once, Run Anywhere” (WORA) principle, ensuring platform independence via the Java Virtual Machine (JVM).

Java is a widely used programming language for coding web applications. It has been a popular choice among developers for over two decades, with millions of Java applications in use today. Java is a multi-platform, object-oriented, and network-centric language that can be used as a platform in itself. It is a fast, secure, reliable programming language for coding everything from mobile apps and enterprise software to big data applications and server-side technologies.

Which of these cannot be used for a variable name in Java?

Java MCQ: Which of these cannot be used for a variable name in Java? a) identifier b) keyword c) variable d) method Answer: b) keyword Explanation: In Java, keywords cannot be used as variable names because they have predefined meanings in the language. Examples of keywords include int, class, public, and void. Reference links: https://www.rameshfadatare.com/learn-java-programming/ […]

Which of these cannot be used for a variable name in Java? Read More »

Which component is used to compile, debug and execute Java programs?

Java MCQ: Which component is used to compile, debug and execute Java programs? a) JDK b) JRE c) JVM d) IDE Answer: a) JDK Explanation: The Java Development Kit (JDK) is the software development environment used to compile, debug, and execute Java programs. It includes the Java compiler, libraries, and tools necessary for Java development.

Which component is used to compile, debug and execute Java programs? Read More »

Identify the interface which is used to declare core methods in Java?

Java MCQ: Identify the interface which is used to declare core methods in Java? a) java.lang.Object b) java.util.List c) java.lang.Runnable d) java.lang.Comparable Answer: d) java.lang.Comparable Explanation: The Comparable interface in Java is used to declare core methods for comparing objects. It defines the compareTo() method, which allows objects to be ordered. This interface is essential

Identify the interface which is used to declare core methods in Java? Read More »

Which of the following exception is thrown when a divide by zero statement is executed?

Java MCQ: Which of the following exception is thrown when a divide by zero statement is executed? a) ArithmeticException b) NullPointerException c) IOException d) ClassNotFoundException Answer: a) ArithmeticException Explanation: In Java, ArithmeticException is thrown when an exceptional arithmetic condition occurs, such as dividing by zero. This is a common runtime exception that does not require

Which of the following exception is thrown when a divide by zero statement is executed? Read More »

What is Runnable?

Java MCQ: What is Runnable? a) An interface b) A class c) A method d) A package Answer: a) An interface Explanation: The Runnable interface in Java is used to define a task that can be executed by a thread. It has a single method, run(), that must be implemented by any class that implements

What is Runnable? Read More »

What is the variables declared in a class for the use of all methods of the class called?

Java MCQ: What is the variables declared in a class for the use of all methods of the class called? a) Instance variables b) Local variables c) Static variables d) Global variables Answer: a) Instance variables Explanation: Instance variables are declared within a class but outside of any method. They are used by all methods

What is the variables declared in a class for the use of all methods of the class called? Read More »

Identify the modifier which cannot be used for constructors.

Java MCQ: Identify the modifier which cannot be used for constructors. a) private b) protected c) final d) public Answer: c) final Explanation: The final modifier cannot be applied to constructors in Java because constructors are not inherited, and hence, there’s no point in preventing inheritance. Other access modifiers like private, protected, and public can

Identify the modifier which cannot be used for constructors. Read More »

Where does the system store parameters and local variables whenever a method is invoked?

Java MCQ: Where does the system store parameters and local variables whenever a method is invoked? a) Stack b) Heap c) Array d) LinkedList Answer: a) Stack Explanation: In Java, parameters and local variables are stored in the stack memory whenever a method is invoked. The stack memory is used for execution of a thread

Where does the system store parameters and local variables whenever a method is invoked? Read More »

What is the output of Math.floor(3.6)?

Java MCQ: What is the output of Math.floor(3.6)? a) 3.0 b) 4.0 c) 3.6 d) 3 Answer: a) 3.0 Explanation: The Math.floor() method in Java returns the largest integer that is less than or equal to the argument passed. For Math.floor(3.6), it returns 3.0. Reference links: https://www.rameshfadatare.com/learn-java-programming/ https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

What is the output of Math.floor(3.6)? Read More »

Total constructors in the String class have?

Java MCQ: Total constructors in the String class have? a) 13 b) 10 c) 12 d) 15 Answer: c) 12 Explanation: The String class in Java has 12 constructors that allow for the creation of strings in various ways, such as from arrays of bytes, characters, and string literals. Reference links: https://www.rameshfadatare.com/learn-java-programming/ https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Total constructors in the String class have? Read More »

In which of the following is toString() method defined?

Java MCQ: In which of the following is toString() method defined? a) java.lang.Object b) java.lang.String c) java.lang.util d) java.lang.Class Answer: a) java.lang.Object Explanation: The toString() method is defined in the java.lang.Object class, which is the superclass of all classes in Java. This method is often overridden to provide a string representation of an object. Reference

In which of the following is toString() method defined? Read More »

Scroll to Top