Java Interview Questions and Answers For Freshers | Best Java Interview Questions and Answers

Java Interview Questions and Answers For Freshers | Online Java MCQ Type Question & Answers Quiz Name Java Interview Questions and Answers Category Reasoning Number of Questions 30 Time 30 Minutes Exam Type MCQ (Multiple Choice Questions) 1. Which of these methods is utilised to make a bit zero defined by the index? a. put() b.... explore below more

Java Interview Questions and Answers For Freshers |  Best Java Interview Questions and Answers (2025)

Java Interview Questions and Answers For Freshers | Online Java MCQ Type Question & Answers

Quiz NameJava Interview Questions and Answers
CategoryReasoning
Number of Questions30
Time30 Minutes
Exam TypeMCQ (Multiple Choice Questions)

1. Which of these methods is utilised to make a bit zero defined by the index?
a. put()
b. set()
c. remove()
d. clear()

2. Which of these classes can return more than one character to the input stream?
a. BufferedReader is a type of buffered reader.
b. Bufferedwriter
c. PushbachReadera
d. CharArrayReader

3. What will be the outcome of compiling and running the given code?

class A int b=10; private A() this.b=7; int f() return b;
class B is an extension of class A
int b; public class Test public static void main (String[] args)
A a = new B(); System.out.println(a.f());
a. Prints 7
b. Prints 0
c.The compilation fails.
d. Produces 10 prints

4. Which of the following declares an abstract method in an abstract Java class?
a. public abstract method();
b. public abstract void method();
c.public void abstract Method();
d. public void method()

5. The method cannot be overridden…..
a.super
b.private
c. static
d. final

6. Except for RuntimeException and Error, what other classes extend Throwable?
a. Error
b. Unchecked Exception
c. Checked Exception
d. None of the above

7. What does JVM stand for?
a.AJAX Virtual Machine
b.Java Supercomputer
c. Java Extremely Small Machine (Java VSM)
d. Java Verified Machine

8. A package is a collection of items…..
a. Classes
b. Interfaces
c. Editing Software
d. Classes and interfaces

9. The hasMoreElements() method of Enumeration has been updated in Iterator to:
a. hasNextElement ()
b.comes next ()
c. hasNext ()
d. name remains unchanged.

10.How do you sort a HashMap based on the values?
a. Enable the Comparator interface and override the compare method.
b. Make use of the Comparator and Comparable interfaces.
c. It is not conceivable.
d. Adherence to the Comparator interface and override the compareTo method.

11.When a class extends the Thread class, it should override the………… method of the Thread class to start that thread.
a. Begin ()
b. run ()
c. begin ()
d. depart ()

12.The exception thrown in the try block is captured in the……….. block.
a. capture
b.hurl
c. throws
d. finally

13. Which of the following ways can be used to generate a sting in an applet?
a. exhibit ()
b. printing ()
c. drawString ()
d. transitory ()

14. Which of the following classes is not a component of Java’s collection framework?
a. Maps
b.Array
c. Stack is a formalised paraphrase.
d. Waiting list

15. Which of the following classes is implemented by the FilterInputStream class?
a. FileInputStream
b.BufferedInputStream
c. InputStream
d. BufferedFileInputStream

16.In Java,………… can only test for equality, whereas……… can evaluate any sort of Boolean expression.
a. If you have a switch, you should use it.
b. if, switch
c. if, break
d. continue if

17. When you send an array to a method, the method receives …..
a.A duplicate of the array
b. The array’s identifier
c. a duplicate of the first element
d. the array’s length

18. Which type modifier is not defined in Java?
a.Vehicle
b. Extern
c. Fill out the registration form
d. all of these

19. Which of these can use the modulus operator (percent)?
a. Integers
b. Floating – point numbers
c.Both A and B
d. None of These

20.Which of the following does not belong: If a class inherits from another class, it should——
a. Override all of its parent class’s methods.
b. Make use of the parent class’s capabilities.
c. Override or add the bare minimum required to achieve the objective of the derived class.
d. Ensure that the result “IS-A-KIND-OF” its base class.

21.Which Set implementation is sorted and synchronised?
a.LinkedHashSet is a type of linked hash set.
b. ConcurrentSkipListSet
c. TreeSet
d. CopyOnWriteArraySet

22. If you try to add the null key to a TreeSet, you’ll get the following error:—-
a.Is planning to compile
b. Exception at Compile Time
c. NullPointerException – Runtime
d. Mistake

23. Which method cannot be overridden?
a. The first variable
b. Last Variable
c. The final class
d. The Last Method

24. Which of the following code segments would run the stored procedure “getPassword()” on a database server?
a. CallableStatement cs = connection.prepareCall(“call.getPassword()”); cs.executeQuery();
b.Callable
c. callable = conn.prepareCall(“call getPassword()”); callable.executeUpdate();
d. Declarable Statement cstate = connect.prepareCall(“call getpassword()”); cstate.executeQuery();

25. Which of the following is a proper HashMap synchronisation syntax?
a. hashMap.synchronizeMap();
b.HashMap map = hashMap.synchronizeMap();
c. Map Collections.synchronizedMap(hashMap);
d.Collection.synchronizeMap(hashMap);

26. Which package is used to facilitate interaction with the garbage collector?
a.java.lang.ref
b. java.lang.reflect
c.java.lang
d. java.awt

27. Which of the following are not Thread class methods?
a. output ()
b. rest (long msec)
c. depart ()
d. halt ()

28. Which of the following class definitions defines a lawful abstract class?
a. class A abstract void unfinished()
b. class A abstract void unfinished();
c. abstract class A abstract void unfinished();
d. public class abstract A abstract void unfinished();

29. In Java, which of the following statements is false?
a.A public member of a class can be accessed from any package.
b. A private member of a class cannot be accessed by methods of the same class.
c.A private member of a class cannot be accessed from a derived class.
d. A protected member of a class can be accessed through its derived class.

30. Which of the following is an excellent example of runtime polymorphism?
a. Overloading of methods
b. Overriding the method
c. Overloading of constructors
d.none of the preceding

About: Nagraj M

I am a Technical Expert with over 10 years of experience working in a MNC company. I specialize in application level technologies and have practical knowledge in various areas. Through my network, I stay updated on the latest news in the IT domain. I want to share new updates, my knowledge and experience through these articles.