100 Top Java Springs Multiple Choice Questions and Answers

Java Springs Multiple Choice Questions:-

1. What is the meaning of the return data type void?
A. Empty memory space is returned so that the developers can utilize it.
B. void returns no data type.
C. void is not supported in Java
D. None of the above
Ans: B

2. A lower precision can be assigned to a higher precision value in Java. For example, a byte type data can be assigned to int type.
A. True
B. False
Ans: B

3. Which of the following statements about the Java language is true?
A. Both procedural and OOP are supported in Java.
B. Java supports only procedural approach towards programming.
C. Java supports only the OOP approach.
D. None of the above.
Ans: A

4. Which of the following statements is false about objects?
A. An instance of a class is an object
B. Objects can access both static and instance data
C. An object is the superclass of all other classes
D. Objects do not permit encapsulation
Ans: D

5. Which methods can access to private attributes of a class?
A. Only Static methods of the same class
B. Only instances of the same class
C. Only methods those defined in the same class
D. Only classes were available in the same package.
Ans: C

6. What is an aggregate object?
A. An object with only primitive attributes
B. An instance of a class which has only static methods
C. An instance which has other objects
D. None of the above
Ans: C

7. Assume that File is an abstract class and has the toFile() method. ImageFile and BinaryFile are concrete classes of the abstract class File.
Also, assume that the method toFile() is implemented in both Binary File and Image File. A File references an ImageFile object in memory and the toFile method is called, which implementation method will be called?
A. Binary File
B. Image File
C. Both File and Binary Files
D. None of the above
Ans: B

8. A class can have many methods with the same name as long as the number of parameters or type of parameters is different. This OOP concept is known as
A. Method Invocating
B. Method Overriding
C. Method Labeling
D. Method Overloading
Ans: D

9. Which of the following is considered as a blueprint that defines the variables and methods common to all of its objects of a specific kind?
A. Object
B. Class
C. Method
D. Real data types
Ans: B

10. What are the two parts of a value of type double?
A. Significant Digits, Exponent
B. Length, Denominator
C. Mode, Numerator
Ans: A

11. After the following code fragment, what is the value in fname?
String str;
int fname;
str = “Foolish boy.”;
fname = str.indexOf(“fool”);
A. 0
B. 2
C. -1
D. 4
Ans: C

12. What is the value of ‘number’ after the following code fragment execution?
int number = 0;
int number2 = 12
while (number < number2)
{
number = number + 1;
}
A. 5
B. 12
C. 21
D. 13
Ans: B

13. Given the following code snippet;
int salaries[;
int index = 0;
salaries = new int salaries[4;
while (index < 4)
{
salaries[index = 10000;
index++;
}
What is the value of salaries [3?
A. 40000
B. 50000
C. 15000
D. 10000
Ans: D

14. Which of the following is not a return type?
A. boolean
B. void
C. public
D. Button
Ans: C

15. If result = 2 + 3 * 5, what is the value and type of ‘result’ variable?
A. 17, byte
B. 25, byte
C. 17, int
D. 25, int
Ans: C

16. What is the data type for the number 9.6352?
A. float
B. double
C. Float
D. Double
Ans: B

17. Assume that the value 3929.92 is of type ‘float’. How to assign this value after declaring the variable ‘interest’ of type float?
A. interest = 3929.92
B. interest = (Float)3929.92
C. interest = 3929.92 (float)
D. interest = 3929.92f
Ans: D

18. Which of the following statements is true?
A. The default char data type is a space( ‘ ‘ ) character.
B. The default integer data type is ‘int’ and real data type is ‘float’
C. The default integer data type is ‘long’ and real data type is ‘float’
D. The default integer data type is ‘int’ and real data type is ‘double’
Ans: D

19. How many numeric data types are supported in Java?
A. 8
B. 4
C. 2
D. 6
Ans: D

20. Which of the following statements declare class Sample to belong to the payroll. admin dept package?
A. package payroll; package admin dept;
B. import payroll.*;
C. package payroll.admindept.Sample;
D. import payroll.admindept.*;
E. package payroll.admindept;
Ans: E

21. The class javA.lang.Exception is
A. protected
B. extends Throwable
C. implements Throwable
D. serializable
Ans: B

22. Which of the following statements is true?
A. An exception can be thrown by throw keyword explicitly.
B. An exception can be thrown by throws keyword explicitly.
Ans: A

23. All the wrapper classes (Integer, Boolean, Float, Short, Long, Double and Character) in java
A. are private
B. are serializable
C. are immutable
D. are final
Ans: D

24. The code snippet
if( “Welcome”.trim() == “Welcome”.trim() )
System.out.println(“Equal”);
else
System.out.println(“Not Equal”);
will
A. compile and display “Equal”
B. compile and display “Not Equal”
C. cause a compiler error
D. compile and display NULL
Ans: C

25. Consider the following code snippet. What will be assigned to the variable fourthChar, if the code is executed?
String str = new String(“Java”);
char fourthChar = str.charAt(4);
A. ‘a’
B. ‘v’
C. throws StringIndexOutofBoundsException
D. null character
Ans: C

26. Which of the following statements is preferred to create a string “Welcome to Java Programming”?
A. String str = “Welcome to Java Programming”
B. String str = new String( “Welcome to Java Programming” )
C. String str; str = “Welcome to Java Programming”
D. String str; str = new String (“Welcome to Java Programming” )
Ans: A

27. Which of the following statements is true?
A. A superclass is a subset of a subclass
B. class ClassTwo extends ClassOne means ClassOne is a subclass
C. class ClassTwo extends ClassOne means ClassTow is a superclass
D. the class Class is the superclass of all other classes in Java.
Ans: A

28. What kind of thread is the Garbage collector thread is?
A. Nondaemon thread
B. Daemon thread
C. Thread with dead state
D. None of the above
Ans: B

29. When a thread terminates its processing, into what state that thread enters?
A. Running state
B. Waiting for state
C. Dead state
D. Beginning state
Ans: C

30. Which statement is true?
A. HashTable is a subclass of Dictionary
B. ArrayList is a subclass of Vector
C. LinkedList is a subclass of ArrayList
D. Vector is a subclass of Stack
Ans: A

31. Which of these statements is true?
A. LinkedList extends List
B. AbstractSet extends Set
C. HashSet extends AbstractSet
D. WeakHashMap extends HashMap
Ans: C

32. Which of the following is synchronized?
A. Set
B. LinkedList
C. Vector
D. WeakHashMap
Ans: C

33. Select all the true statements from the following.
A. AbstractSet extends AbstractCollection
B. AbstractList extends AbstractCollection
C. HashSet extends AbstractSet
D. Vector extends AbstractList
E. All of the above
Ans: E

34. Which of the methods should be implemented if any class implements the Runnable interface?
A. start()
B. run()
C. wait()
D. notify() and notifyAll()
Ans: B

35. A thread which has invoked wait() method of an object, still owns the lock of the object. Is this statement true or false?
A. True
B. False
Ans: B

JAVA SPRINGS Objective Questions Pdf Free Download::

36. Which of the following is not a method of the Thread class.
A. public void run()
B. public void start()
C. public void exit()
D. public final int getPriority()
Ans: C

37. To execute the threads one after another
A. the keyword synchronized is used
B. the keyword synchronizable is used
C. the keyword synchronized is used
D. None of the above
Ans: B

38. The object of DataInputStream is used to
A. To convert the binary stream into a character stream
B. To covert character stream into a binary stream
C. To write data onto the output object
D. All of the above
Ans: A

39. DataInputStream is an example of
A. Output stream
B. I/O stream
C. Filtered stream
D. File stream
Ans: C

40. From an MVC perspective, Struts provides the
A. Model
B. View
C. Controller
Ans: B

41. Consider the following program:
import myLibrary.*;
public class show some class
{
// code for the class…
}
What is the name of the java file containing this program?
A. myLibrary.java
B. ShowSomeClass.java
C. show some class
D. ShowSomeClass.class
E. Any file name with the java suffix will do
Ans: B

42. Which of the following is TRUE?
A. In Java, an instance field declared public generates a compilation error.
B. it is the name of a class available in the package javA.lang
C. Instance variable names may only contain letters and digits.
D. A class has always a constructor (possibly automatically supplied by the java compiler).
E. The more comments in a program, the faster the program runs.
Ans: D

43.Consider the following code snippet
String river = new String(“Columbia”);
System.out.println(river.length());
What is printed?
A. 6
B. 7
C. 8
D. Columbia
E. River
Ans: C

44. A constructor
A. must have the same name as the class it is declared within.
B. is used to create objects.
C. may be declared private
D. A and B
E. A, B, and C
Ans: E

45. Which of the following may be part of a class definition?
A. instance variables
B. instance methods
C. constructors
D. all of the above
E. none of the above
Ans: D

46. What is different between a Java applet and a Java application?
A. An application can, in general, be trusted whereas an applet can’t.
B. An applet must be executed in a browser environment.
C. An applet is not able to access the files of the computer it runs on
D. (A), (B) and (C).
E. None of the above
Ans: D

47.Consider
public class MyClass{
public MyClass(){/*code*/}
// more code…
}
To instantiate MyClass, you would write?
A. MyClass mc = new MyClass();
B. MyClass mc = MyClass();
C. MyClass mc = MyClass;
D. MyClass mc = new MyClass;
E. It can’t be done. The constructor of MyClass should be defined as public void MyClass(){/*code*/}
Ans: A

48.What is byte code in the context of Java?
A. The type of code generated by a Java compiler
B. The type of code generated by a Java Virtual Machine
C. It is another name for a Java source file
D. It is the code written within the instance methods of a class.
E. It is another name for comments written within a program.
Ans: A

49. What is garbage collection in the context of Java?
A. The operating system periodically deletes all of the java files available on the system.
B. Any package imported in a program and not used is automatically deleted.
C. When all references to an object are gone, the memory used by the object is automatically reclaimed.
D. The JVM checks the output of any Java program and deletes anything that doesn’t make sense.
E. Janitors working for Sun MicroSystems are required to throw away any Microsoft documentation found in the employees’ offices.
Ans: c

50. You read the following statement in a Java program that compiles and executes.
submarine.dive(depth);
What can you say for sure?
A. depth must be an int
B. dive must be a methoD.(and)
C. dive must be the name of an instance field.
D. submarine must be the name of a class
E. submarine must be a method.
Ans: B

51.  Formed on a diskette (or hard drive) during initialization.
A. source code
B. images
C. sectors
D. storage units
Ans: C

52.  The CPU consists of:
A. Control Unit, Temporary Memory, Output
B. Control Unit, Arithmetic Logic Unit, Temporary Memory
C. Input, Process, Storage, Output
D. Input, Control Unit, Arithmetic Logic Unit, Output
Ans: B

53.  OOP stands for:
A. Observable Object Programming
B. Object Observed Procedures
C. Object-Oriented Programming
D. Object Overloading Practices
Ans: C

54.  Output printed on paper.
A. softcopy
B. hardcopy
C. source code
D. software
Ans: B

55.  A binary digit (1 or 0) signifying “on” or “off”.
A. bit
B. byte
C. megabyte
D. gigabyte
Ans: A

56.  Our decimal number 44, when represented in binary, is:
A. 101100
B. 101010
C. 111000
D. 10100
Ans: A

57.  Byte code is the machine language for a hypothetical computer called the:
A. Java Byte Code Compiler
B. Java Byte Code Interpreter
C. Java Virtual Machine
D. Java Memory Machine
Ans: C

58.  Equals 8 bits.
A. megabyte
B. gigabyte
C. sector
D. byte
Ans: D

59.  Java allows for three forms of commenting:
A. // single line, ** block lines, /*/ documentation
B. // single line, /*…*/ block lines, /**…*/ documentation
C. / single line, /* block lines, ** documentation
D. // single line, //…// block lines, //*…*// documentation
Ans: B

60.  To prepare a diskette (or hard drive) to receive information.
A. format
B. track
C. interpret
D. boot
Ans: A

61.  In Java, the name of the class must be the same as the name of the .java file.
A. false
B. true – but case sensitivity does not apply
C. true – but additional numbers may be added to the name
D. true
Ans: D

62.  The name Java was derived from
A. a cup of coffee
B. an acronym for JBuilder Activated Variable Assembly
C. an acronym for Juxtapositioned Activated Variable Actions
D. an acronym for John’s Answer for Various Accounts
Ans: A

63.  Programs that tell a computer what to do.
A. hardware
B. software
C. hard copy
D. projects
Ans: B

64.  RAM stands for _________.
A. Read Anytime Memory
B. Read Allocated Memory
C. Random Access Memory
D. Random Allocated Memory
Ans: C

65.  Several computers linked to a server to share programs and storage space.
A. library
B. grouping
C. network
D. integrated system
Ans: C

66.  Source code in Java will not run if it is not indenteD.
A. true
B. false
Ans: B

67.  When working in Java with JBuilder, each program you write should be assigned to a new project.
A. true
B. false
Ans: A

68.  The four equipment functions of a computer system.
A. Input, Process, Control Unit, Output
B. Input, Control Unit, Arithmetic Logic Unit, Output
C. Input, Process, Storage, Output
D. Input, Process, Library Linking, Output
Ans: C

69.  Translates and executes a program line by line.
A. compiler
B. interpreter
C. linker
D. control unit
Ans: B

70.  The physical components of a computer system.
A. control unit
B. hardware
C. software
D. ALU
Ans: B