610+ Java Programming Solved MCQs

401.

Java is designed for _______ environment of the internet.

A. development.
B. deducting.
C. distributed.
D. web design.
Answer» C. distributed.
402.

______ is a small unit of a process.

A. method.
B. thread.
C. applet.
D. stream.
Answer» B. thread.
403.

Wrapper class is a wrapper around a _______ data type.

A. normal.
B. central.
C. primitive.
D. concrete.
Answer» C. primitive.
404.

Once an interface has been defined, one or more _____ can implement that interface.

A. class.
B. object.
C. methods.
D. keywords.
Answer» A. class.
405.

Variable declared as _________ do not occupy memory on a per instance basis.

A. static.
B. final.
C. abstract.
D. Ccde.
Answer» B. final.
406.

______ must be the first statement executed inside a subclass Constructor.

A. final().
B. super().
C. static().
D. dec().
Answer» B. super().
407.

The ________ connects classes and objects.

A. dot.
B. super.
C. new.
D. variable.
Answer» A. dot.
408.

The ________ statement is used to terminate a statement sequence.

A. break.
B. switch.
C. continue.
D. wait.
Answer» A. break.
409.

Multidimensional arrays are actually __________.

A. arrays of element.
B. arrays and variable.
C. arrays of arrays.
D. arrays of Square.
Answer» C. arrays of arrays.
410.

______ statement in java is multiway branch statement.

A. declaration.
B. case.
C. multi.
D. switch.
Answer» D. switch.
411.

_______ can be declared inside interface declarations.

A. Variables.
B. Classes.
C. Methods.
D. Keywords.
Answer» A. Variables.
412.

The _______ supports several constructors to create an empty String.

A. string class.
B. super class.
C. empty class.
D. upper class.
Answer» B. super class.
413.

__________ is used for initialize the value to the String object.

A. character literals.
B. string literals.
C. string group literals.
D. group literals.
Answer» B. string literals.
414.

____ operators which concatenates two strings.

A. +.
B. ++.
C. -.
D. ++, ++.
Answer» A. +.
415.

_______ method is a thread mechanism.

A. synchronize.
B. user defined.
C. keyword.
D. normal.
Answer» A. synchronize.
416.

Java programs are _________ independent.

A. platform.
B. procedural.
C. high level.
D. Secure.
Answer» A. platform.
417.

A java program can be run in any computer running under any ________.

A. operating system.
B. interface system.
C. machine system.
D. moral system.
Answer» A. operating system.
418.

A java program must contain a______ method.

A. user defined.
B. main.
C. local.
D. return.
Answer» B. main.
419.

Which of these class holds a collection of static methods and variables?.

A. Void .
B. Process.
C. Runtime .
D. System.
Answer» D. System.
420.

_________ operator is used to create an array.

A. new .
B. public.
C. key.
D. main.
Answer» A. new .
421.

Which of these class is used to create an object whose character sequence is mutable?.

A. String().
B. StringBuffer().
C. Both of the mentioned.
D. None of the mentioned.
Answer» B. StringBuffer().
422.

The variable defined in class is called ________ variable.

A. local.
B. minimum.
C. instance.
D. define.
Answer» C. instance.
423.

A special type of method that is used to initialize an object is called________.

A. constructor.
B. destructor.
C. modification.
D. editor.
Answer» A. constructor.
424.

Class is considered ________ of an object and instance.

A. min.
B. local.
C. template.
D. keyword.
Answer» C. template.
425.

String constants are said to be_____ of string class.

A. objects.
B. char.
C. data.
D. variable.
Answer» A. objects.
426.

Methods having same name and differ type signature are called _____methods.

A. overriding.
B. over read.
C. super.
D. overloading.
Answer» D. overloading.
427.

Methods having same name, same type signature are called _____ methods.

A. overriding.
B. overloading.
C. overwriting.
D. overreading.
Answer» A. overriding.
428.

A method without the body is called ________ method.

A. view.
B. class.
C. abstract.
D. user defined.
Answer» C. abstract.
429.

A class having an abstract method is to be declared as _______.

A. class.
B. abstract.
C. class name.
D. method name.
Answer» B. abstract.
430.

Package statement helps to create many classes to have ______ name.

A. differ.
B. vanity.
C. same.
D. punch.
Answer» C. same.
431.

The default package that is implicitly called in a java program is _________.

A. java.Lang.
B. java.System.
C. java. Window.
D. java.Lang.System.
Answer» A. java.Lang.
432.

User defined exception can be created using _________ class.

A. catch.
B. try.
C. throwable.
D. get.
Answer» C. throwable.
433.

Which of these keywords is not a part of exception handling?.

A. finally.
B. catch.
C. thrown.
D. try.
Answer» C. thrown.
434.

Exception that is identified during compile time is called ______ exception.

A. user defined.
B. checked.
C. undefined.
D. defined.
Answer» B. checked.
435.

When several tasks are handled by a single CPU, it is called _________.

A. multitasking.
B. task.
C. simultaneous.
D. taker.
Answer» A. multitasking.
436.

Threads can be created by extending _________ class.

A. new.
B. operator.
C. thread.
D. super thread.
Answer» C. thread.
437.

Threads can be created by implementing ________ interface.

A. new.
B. creator.
C. main.
D. runnable.
Answer» D. runnable.
438.

When a thread is created using new operator, the thread is in _____ state.

A. new.
B. old.
C. horizontal.
D. default.
Answer» A. new.
439.

At any one instance of time _____ threads will be in running state.

A. many.
B. two.
C. three.
D. one.
Answer» D. one.
440.

Which of these classes are used by character streams for input and output operations?.

A. InputStream.
B. Writer.
C. ReadStream.
D. InputOutputStream.
Answer» B. Writer.
441.

The wrapper classes are defined in _________ packages.

A. java. Lan.
B. java. Lang.
C. java. Nill.
D. java.Math.
Answer» B. java. Lang.
442.

The capacity if StringBuffer is defined as _________.

A. Length+12.
B. Length+13.
C. Length+15.
D. Length+16.
Answer» D. Length+16.
443.

To compare the contents of two objects ______ method is used.

A. equals.
B. not equals.
C. multiple.
D. delay.
Answer» A. equals.
444.

Which of these class is used to read from byte array?.

A. InputStream.
B. BufferedInputStream.
C. ArrayInputStream.
D. ByteArrayInputStream.
Answer» D. ByteArrayInputStream.
445.

Graphics object can only be drawn on _________.

A. view.
B. windows.
C. applet.
D. zoom.
Answer» B. windows.
446.

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.
Answer» A. The type of code generated by a Java compiler.
447.

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.
Answer» C. When all references to an object are gone, the memory used by the object is~~~automatically reclaimed.
448.

What output is displayed as the result of executing the following statement?System.out.println ("// Looks like a comment.");

A. // Looks like a comment.
B. The statement results in a compilation error.
C. Looks like a comment.
D. No output is displayed.
Answer» C. Looks like a comment.
449.

In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?

A. It must have a package statement.
B. It must be named Test.java.
C. It must import java.lang.
D. It must declare a public class named Test.
Answer» B. It must be named Test.java.
450.

What is the value of a [3] as the result of the following array declaration?

A. 1.
B. 2.
C. 3.
D. 4.
Answer» D. 4.
451.

Which of these data tupe can be used for a method having a return statement in it?.

A. void.
B. int.
C. float.
D. All of the mentioned.
Answer» D. All of the mentioned.
452.

What is an example of polymorphism?

A. inner class.
B. anonymous classes.
C. method overloading.
D. method overriding.
Answer» C. method overloading.
453.

An interface contains __________ methods.

A. non-abstract.
B. implemented.
C. unimplemented.
D. abstract.
Answer» C. unimplemented.
454.

Which of the following is not a wrapper class?

A. string.
B. integer.
C. boolean.
D. character.
Answer» A. string.
455.

Which of these is the method which is executed first before execution of any other thing takes place in a program?.

A. main method.
B. finalize method.
C. static method.
D. private method.
Answer» C. static method.
456.

Which of the following methods are methods of the String class?

A. delete( ).
B. append( ).
C. reverse( ).
D. replace( ).
Answer» D. replace( ).
457.

If you run the code below, what gets printed out?String s=new String ("Bicycle"); int iBegin=1; char iEnd=3; System.out.println (s.substring (iBegin, iEnd));

A. Bic.
B. ic.
C. icy.
D. error: no method matching substring(int, char).
Answer» B. ic.
458.

Given the following declarations String s1=new String("Hello") ; String s2=new String("there"); String s3=new String(); Which of the following are legal operations?

A. s3=s1 + s2;.
B. s3=s1 - s2;.
C. s3=s1 & s2.
D. s3=s1 && s2.
Answer» A. s3=s1 + s2;.
459.

Which of the following classes is used to perform basic console I/O?

A. system.
B. security Manager.
C. math.
D. runtime.
Answer» A. system.
460.

Which of these keywords is used to define packages in Java?,

A. pkg
B. Pkg.
C. package.
D. Package.
Answer» C. package.
461.

Which of the following are true about the Error and Exception classes?

A. Both classes extend Throwable.
B. The Error class is final and the Exception class is not.
C. The Exception class is final and the Error is not.
D. Both classes implement Throwable.
Answer» A. Both classes extend Throwable.
462.

Which of the following are true?

A. The Void class extends the Class class.
B. The Float class extends the Double class.
C. The System class extends the Runtime class.
D. The Integer class extends the Number class.
Answer» D. The Integer class extends the Number class.
463.

Which of the following will output -4.0?

A. System.out.println(Math.floor(-4.7));.
B. System.out.println(Math.round(-4.7));.
C. System.out.println(Math.ceil(-4.7));.
D. System.out.println(Math.Min(-4.7));.
Answer» C. System.out.println(Math.ceil(-4.7));.
464.

What is the default return type to main() __________.

A. void.
B. double.
C. float.
D. int.
Answer» D. int.
465.

Which of the following statements are true?

A. UTF characters are all 8-bits.
B. UTF characters are all 16-bits.
C. UTF characters are all 24-bits.
D. Unicode characters are all 16-bits.
Answer» D. Unicode characters are all 16-bits.
466.

You execute the code below in an empty directory. What is the result? File f1 = new File ("dirname");F ile f2 = new File (f1, "filename");

A. A new directory called dirname is created in the current working directory.
B. A new directory called dirname is created in the current working directory.
C. A new file called filename is created in the current working directory.
D. No directory is created, and no file is created.
Answer» C. A new file called filename is created in the current working directory.
467.

How do you create a Reader object from an InputStream object?

A. Use the static createReader( ) method of InputStream class.
B. Use the static createReader( ) method of Reader class.
C. Create an InputStreamReader object, passing the InputStream object as an argument to the InputStreamReader constructor.
D. Create an OutputStreamReader object, passing the InputStream object as an argument to the OutputStreamReader constructor.
Answer» C. Create an InputStreamReader object, passing the InputStream object as an argument to the InputStreamReader constructor.
468.

How can you change the current working directory using an instance of the File class called FileName?

A. FileName.chdir("DirName").
B. FileName.cd("DirName").
C. FileName.cwd("DirName").
D. The File class does not support directly changing the current directory.
Answer» D. The File class does not support directly changing the current directory.
469.

Which of these is a mechanism for naming and visibility control of a class and its content?.

A. Object.
B. Packages.
C. Interfaces.
D. None of the Mentioned.
Answer» B. Packages.
470.

Which of the following is correct way of importing an entire package named as pkg?.

A. import pkg.
B. Import pkg.
C. import pkg.*.
D. Import pkg.*
Answer» C. import pkg.*.
471.

Which of these is correct way of calling a constructor having no parameters, of superclass A by subclass B?.

A. super(void);.
B. superclass.();.
C. super.A();.
D. super();.
Answer» D. super();.
472.

Suppose A is an abstract class ,B is a concrete subclass of A, and both A and B have an default constructor. Which of the following is correct? a) A a = new A(); b)A a = new B(); c) B b = new A(); d) B b = new B();

A. Both a & b.
B. Both b & d.
C. Both b & c.
D. Both a & c.
Answer» B. Both b & d.
473.

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 method(){ };.
D. private abstract void method(){ };.
Answer» B. public abstract void method();.
474.

Which of these keywords are used to define an abstract class?.

A. abst
B. abstract
C. Abstract
D. abstract class
Answer» B. abstract
475.

Which of these is not a correct statement?.

A. Every class containing abstract method must be declared abstract.
B. Abstract class defines only the structure of the class not its implementation.
C. Abstract class can be initiated by new operator.
D. Abstract class can be inherited.
Answer» C. Abstract class can be initiated by new operator.
476.

Which of the following statements about the try{} block in Java is false?

A. Some of the statements in a try{} block will never throw an exception.
B. The try{} block must appear before the catch{} blocks.
C. The try{} block cannot contain loops or branches.
D. The statements in a try{} block may throw several types of exception.
Answer» C. The try{} block cannot contain loops or branches.
477.

The concept of multiple inheritance is implemented in Java by ____ (i.) extending two or more classes (ii.) extending one class and implementing one or more interfaces (iii.) implementing two or more interfaces (iv.) all of these

A. (i), (ii), (iii) & (iv)
B. (i) only
C. (i) & (iii) only
D. (ii) & (iii) only
Answer» D. (ii) & (iii) only
478.

What is polymorphism in Java? .

A. It is when a single super class has many subclasses.
B. It is when a single variable is used with several different types of related objects.
C. It is when a program uses several different types of objects, each with its own variable.
D. It is when a class has several methods with the same name but different parameter types.
Answer» D. It is when a class has several methods with the same name but different parameter types.
479.

What code would you use to construct a 24-point bold serif font?

A. new Font (Font. SERIF, 24,Font.BOLD);.
B. new Font("SERIF", Font.BOLD,24);.
C. new Font("BOLD ", 24,Font.SERIF);.
D. new Font (Font. SERIF, "BOLD", 24);.
Answer» B. new Font("SERIF", Font.BOLD,24);.
480.

A / An ________ variable is shared by all instances of the class. It exists even before an object is created.

A. instance
B. abstract
C. interface
D. static
Answer» A. instance
481.

The concept of derived classes is involved in _________.

A. encapsulation.
B. information hiding.
C. polymorphism.
D. inheritance.
Answer» C. polymorphism.
482.

Which of these keywords is used by a class to use an interface defined previously?.

A. import.
B. imports.
C. implements.
D. implement.
Answer» C. implements.
483.

super keyword can be used to _____.

A. call super class constructor.
B. access super class member
C. both a and b.
D. none of the above
Answer» C. both a and b.
484.

Overloaded methods ___.

A. are a group of methods with the same name.
B. have the same number and type of arguments.
C. make life simpler for programmer.
D. may fail unexpectedly due to stress.
Answer» A. are a group of methods with the same name.
485.

____ are automatically called when an object is destroyed.

A. collectGarbage().
B. Destructor().
C. finalize().
D. final().
Answer» C. finalize().
486.

___ keyword is used to refer to the current object.

A. super.
B. this.
C. new.
D. volatile.
Answer» B. this.
487.

When a class is declared as final , then ____.

A. It can not be inherited
B. It must be inherited
C. Its object can not be created
D. none of these
Answer» A. It can not be inherited
488.

When method is overridden , then by subclass object which class method is called _____.

A. super class.
B. subclass.
C. both.
D. none
Answer» A. super class.
489.

Before doing garbage collection , _____ method is called .

A. main().
B. finalize().
C. final().
D. collect().
Answer» B. finalize().
490.

The .dot operator connects the following two entities _____.

A. a class member and a class object
B. a class object and a class
C. a class and a member of that class.
D. a class object and a member of that class.
Answer» A. a class member and a class object
491.

Which layout should you use to organize the components of a container in a tabular~~~form?

A. Card Layout.
B. BorederLayout.
C. Flow Layout.
D. Grid Layout.
Answer» D. Grid Layout.
492.

An Applet has its Layout Manager set to the default of FlowLayout. What code~~~would be the correct to change to another Layout Manager?

A. setLayoutManager(new GridLayout());.
B. setLayout(new GridLayout(2,2));.
C. setGridLayout(2,2,)).
D. setBorderLayout();.
Answer» B. setLayout(new GridLayout(2,2));.
493.

How do you indicate where a component will be positioned using Flowlayout?

A. North, South, East, West.
B. Assign a row/column grid reference.
C. Pass a X/Y percentage parameter to the add method.
D. Do nothing, the FlowLayout will position the component.
Answer» D. Do nothing, the FlowLayout will position the component.
494.

How do you change the current layout manager for a container?

A. Use the setLayout method.
B. Once created you cannot change the current layout manager of a component.
C. Use the setLayoutManager method.
D. Use the updateLayout method.
Answer» A. Use the setLayout method.
495.

Which of the following may contain a menu bar?

A. A panel.
B. A frame.
C. An applet.
D. A menu bar.
Answer» B. A frame.
496.

What will be the content of array variable table after executing the following code?

for (int i = 0; i < 3; i++) {
for (int j = 0; j < 3; j++) {
if (j == i) {
table[i][j] = 1;
} else {
table[i][j] = 0;
}
}
}

A. 0 0 0 0 0 0 0 0 0.
B. 1 0 0 1 1 0 1 1 1.
C. 1 0 0 0 1 0 0 0 1.
D. 0 0 1 0 1 0 1 0 0.
Answer» C. 1 0 0 0 1 0 0 0 1.
497.

Which of the following classes are not available in the java.lang package?

A. Stack.
B. Object.
C. Math.
D. String.
Answer» A. Stack.
498.

Which of the following are not the wrapper classes?

A. Byte.
B. Vector.
C. Integer.
D. Short.
Answer» C. Integer.
499.

Which of the following method is not belonging to the String class?

A. length().
B. reverse().
C. compareTo() .
D. equals().
Answer» B. reverse().
500.

If not assigned a value, a variable of type char has the following default value:

A. \uffff'.
B. \u0000'.
C. " " (space).
D. '\u0001'.
Answer» B. \u0000'.
Tags
  • Question and answers in Java Programming,
  • Java Programming multiple choice questions and answers,
  • Java Programming Important MCQs,
  • Solved MCQs for Java Programming,
  • Java Programming MCQs with answers PDF download