Author name: admin

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 »

Arrays in Java are?

Java MCQ: Arrays in Java are? a) Objects b) Primitive data types c) Methods d) None of the above Answer: a) Objects Explanation: In Java, arrays are considered objects. This means they are instances of a class, and they have a built-in field length that stores their size. Reference links: https://www.rameshfadatare.com/learn-java-programming/ https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Arrays in Java are? Read More »

Number of primitive data types in Java are?

Java MCQ: Number of primitive data types in Java are? a) 6 b) 7 c) 8 d) 9 Answer: c) 8 Explanation: Java has 8 primitive data types: byte, short, int, long, float, double, char, and boolean. These data types serve as the building blocks for data manipulation in Java. Reference links: https://www.rameshfadatare.com/learn-java-programming/ https://www.javaguides.net/p/java-tutorial-learn-java-programming.html

Number of primitive data types in Java are? Read More »

What is the main difference between HashMap and Hashtable?

Java MCQ: What is the main difference between HashMap and Hashtable? a) HashMap is unsynchronized, Hashtable is synchronized b) HashMap allows null keys and values, Hashtable does not c) HashMap is generally faster than Hashtable d) All of the above Answer: d) All of the above Explanation: The main differences between HashMap and Hashtable are:

What is the main difference between HashMap and Hashtable? Read More »

Scroll to Top