Java-Programming (Set 5)
Java-Programming (Set 5)
Java-Programming (Set 5)
5 of 7 sets
404. Once an interface has been defined, one or more _____ can implement that
interface.
A. class.
B. object.
C. methods.
D. keywords.
Answer:A
406. ______ must be the first statement executed inside a subclass Constructor.
A. final().
B. super().
C. static().
D. dec().
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
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
419. Which of these class holds a collection of static methods and variables?.
A. Void .
B. Process.
C. Runtime .
D. System.
Answer:D
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
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
430. Package statement helps to create many classes to have ______ name.
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
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 _________.
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?.
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.
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
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
459. Which of the following classes is used to perform basic console I/O?
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
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
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.
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
473. Which of the following declares an abstract method in an abstract Java class?
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
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
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
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));.
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
496. What will be the content of array variable table after executing the following
code?
497. Which of the following classes are not available in the java.lang package?
A. Stack.
B. Object.
C. Math.
D. String.
Answer:A
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