Java-Programming (Set 5)

Download as pdf or txt
Download as pdf or txt
You are on page 1of 21

Java Programming

5 of 7 sets

401. Java is designed for _______ environment of the internet.


A. development.
B. deducting.
C. distributed.
D. web design.
Answer:C

402. ______ is a small unit of a process.


A. method.
B. thread.
o m
C. applet.
. c
D. stream.
te
Answer:B a
q M
c
403. Wrapper class is a wrapper around a _______ data type.
A. normal.
B. central.
M
C. primitive.
D. concrete.
Answer:C

404. Once an interface has been defined, one or more _____ can implement that
interface.
A. class.
B. object.
C. methods.
D. keywords.
Answer:A

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


basis.
A. static.
B. final.
C. abstract.
D. Ccde.
Answer:B

406. ______ must be the first statement executed inside a subclass Constructor.
A. final().
B. super().
C. static().
D. dec().
Answer:B

407. The ________ connects classes and objects.


A. dot.
B. super.
C. new.
D. variable.
Answer:A

408. The ________ statement is used to terminate a statement sequence.


A. break.
B. switch.
C. continue.
D. wait.
Answer:A

409. Multidimensional arrays are actually __________.


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

410. ______ statement in java is multiway branch statement.

View all MCQ's at McqMate.com


A. declaration.
B. case.
C. multi.
D. switch.
Answer:D

411. _______ can be declared inside interface declarations.


A. Variables.
B. Classes.
C. Methods.
D. Keywords.
Answer:A

412. The _______ supports several constructors to create an empty String.


A. string class.
B. super class.
C. empty class.
D. upper class.
Answer:B

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

414. ____ operators which concatenates two strings.


A. +.
B. ++.
C. -.
D. ++, ++.
Answer:A

415. _______ method is a thread mechanism.

View all MCQ's at McqMate.com


A. synchronize.
B. user defined.
C. keyword.
D. normal.
Answer:A

416. Java programs are _________ independent.


A. platform.
B. procedural.
C. high level.
D. Secure.
Answer:A

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

418. A java program must contain a______ method.


A. user defined.
B. main.
C. local.
D. return.
Answer:B

419. Which of these class holds a collection of static methods and variables?.
A. Void .
B. Process.
C. Runtime .
D. System.
Answer:D

420. _________ operator is used to create an array.

View all MCQ's at McqMate.com


A. new .
B. public.
C. key.
D. main.
Answer:A

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

422. The variable defined in class is called ________ variable.


A. local.
B. minimum.
C. instance.
D. define.
Answer:C

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

424. Class is considered ________ of an object and instance.


A. min.
B. local.
C. template.
D. keyword.
Answer:C

425. String constants are said to be_____ of string class.

View all MCQ's at McqMate.com


A. objects.
B. char.
C. data.
D. variable.
Answer:A

426. Methods having same name and differ type signature are called
_____methods.
A. overriding.
B. over read.
C. super.
D. overloading.
Answer:D

427. Methods having same name, same type signature are called _____ methods.
A. overriding.
B. overloading.
C. overwriting.
D. overreading.
Answer:A

428. A method without the body is called ________ method.


A. view.
B. class.
C. abstract.
D. user defined.
Answer:C

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


A. class.
B. abstract.
C. class name.
D. method name.
Answer:B

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

View all MCQ's at McqMate.com


A. differ.
B. vanity.
C. same.
D. punch.
Answer:C

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

432. User defined exception can be created using _________ class.


A. catch.
B. try.
C. throwable.
D. get.
Answer:C

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


A. finally.
B. catch.
C. thrown.
D. try.
Answer:C

434. Exception that is identified during compile time is called ______ exception.
A. user defined.
B. checked.
C. undefined.
D. defined.
Answer:B

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

View all MCQ's at McqMate.com


A. multitasking.
B. task.
C. simultaneous.
D. taker.
Answer:A

436. Threads can be created by extending _________ class.


A. new.
B. operator.
C. thread.
D. super thread.
Answer:C

437. Threads can be created by implementing ________ interface.


A. new.
B. creator.
C. main.
D. runnable.
Answer:D

438. When a thread is created using new operator, the thread is in _____ state.
A. new.
B. old.
C. horizontal.
D. default.
Answer:A

439. At any one instance of time _____ threads will be in running state.
A. many.
B. two.
C. three.
D. one.
Answer:D

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

View all MCQ's at McqMate.com


A. InputStream.
B. Writer.
C. ReadStream.
D. InputOutputStream.
Answer:B

441. The wrapper classes are defined in _________ packages.


A. java. Lan.
B. java. Lang.
C. java. Nill.
D. java.Math.
Answer:B

442. The capacity if StringBuffer is defined as _________.


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

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


A. equals.
B. not equals.
C. multiple.
D. delay.
Answer:A

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


A. InputStream.
B. BufferedInputStream.
C. ArrayInputStream.
D. ByteArrayInputStream.
Answer:D

445. Graphics object can only be drawn on _________.

View all MCQ's at McqMate.com


A. view.
B. windows.
C. applet.
D. zoom.
Answer:B

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

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

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

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.

View all MCQ's at McqMate.com


Answer:B

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

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

452. What is an example of polymorphism?


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

453. An interface contains __________ methods.


A. non-abstract.
B. implemented.
C. unimplemented.
D. abstract.
Answer:C

454. Which of the following is not a wrapper class?


A. string.
B. integer.
C. boolean.
D. character.

View all MCQ's at McqMate.com


Answer:A

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

456. Which of the following methods are methods of the String class?
A. delete( ).
B. append( ).
C. reverse( ).
D. replace( ).
Answer:D

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

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

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

View all MCQ's at McqMate.com


A. system.
B. security Manager.
C. math.
D. runtime.
Answer:A

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


A. pkg
B. Pkg.
C. package.
D. Package.
Answer:C

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

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

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

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

View all MCQ's at McqMate.com


A. void.
B. double.
C. float.
D. int.
Answer:D

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

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

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

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.

View all MCQ's at McqMate.com


Answer:D

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

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

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

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

473. Which of the following declares an abstract method in an abstract Java class?

View all MCQ's at McqMate.com


A. public abstract method();.
B. public abstract void method();.
C. public void method(){ };.
D. private abstract void method(){ };.
Answer:B

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


A. abst
B. abstract
C. Abstract
D. abstract class
Answer:B

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

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

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

View all MCQ's at McqMate.com


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

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

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

481. The concept of derived classes is involved in _________.


A. encapsulation.
B. information hiding.
C. polymorphism.
D. inheritance.
Answer:C

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


previously?.
A. import.
B. imports.
C. implements.
D. implement.

View all MCQ's at McqMate.com


Answer:C

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

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

485. ____ are automatically called when an object is destroyed.


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

486. ___ keyword is used to refer to the current object.


A. super.
B. this.
C. new.
D. volatile.
Answer:B

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

View all MCQ's at McqMate.com


Answer:A

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

489. Before doing garbage collection , _____ method is called .


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

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

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

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));.

View all MCQ's at McqMate.com


C. setGridLayout(2,2,)).
D. setBorderLayout();.
Answer:B

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

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

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

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;
}
}
}

View all MCQ's at McqMate.com


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

497. Which of the following classes are not available in the java.lang package?
A. Stack.
B. Object.
C. Math.
D. String.
Answer:A

498. Which of the following are not the wrapper classes?


A. Byte.
B. Vector.
C. Integer.
D. Short.
Answer:C

499. Which of the following method is not belonging to the String class?
A. length().
B. reverse().
C. compareTo() .
D. equals().
Answer:B

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

View all MCQ's at McqMate.com

You might also like