Download JAVA Multiple Choice Questions and more Quizzes Java Programming in PDF only on Docsity!
1. Java programs are A) Faster than others B) Platform independent C) Not reusable D) Not scalable 2. Java has its origin in A) C programming language B) PERRL C) COBOL D) Oak programming language 3. Which one of the following is true for Java A) Java is object-oriented and interpreted B) Java is efficient and faster than C C) Java is the choice of everyone. D) Java is not robust. 4. The command javac is used to A) debug a java program B) compile a java program C) interpret a java program D) execute a java program 5. Java servlets are an efficient and powerful solution for creating ………….. for the web. A) Dynamic content B) Static content C) Hardware D) Both a and b 6. Filters were officially introduced in the Servlet ……………… specification. A) 2. B) 2. C) 2. D) 2. 7. Which is the root class of all AWT events A) java.awt.ActionEvent B) java.awt.AWTEvent C) java.awt.event.AWTEvent D) java.awt.event.Event 8. OOP features are i) Increasing productivity ii) Reusability iii) Decreasing maintenance cost iv) High vulnerability A) 1,2 & 4 B) 1,2 & 3 C) 1, 2 & 4 D) none of the above 9. break statement is used to i) get out of method ii) end a program
iii) get out of a loop iv) get out of the system A) 1 & 2 B) 1,2 & 3 C) 1 & 3 D) 3
10. Native-protocol pure Java converts ……….. into the ………… used by DBMSs directly. A) JDBC calls, network protocol B) ODBC class, network protocol C) ODBC class, user call D) JDBC calls, user call Answers:
- B) Platform independent
- D) Oak programming language
- A) Java is object …… interpreted
- B) compile a java program
- A) Dynamic content
- B) 2.
- B) java.awt.AWTEvent
- B) 1,2 & 3
- D) 3
- A) JDBC calls, ……protocol 1. The JDBC-ODBC bridge allows ……….. to be used as ……….. A) JDBC drivers, ODBC drivers B) Drivers, Application C) ODBC drivers, JDBC drivers D) Application, drivers 2. Which of the following is true about Java. A) Java does not support overloading. B) Java has replaced the destructor function of C++ C) There are no header files in Java. D) All of the above. 3. ……………. are not machine instructions and therefore, Java interpreter generates machine code that can be directly executed by the machine that is running the Java program. A) Compiled Instructions B) Compiled code C) byte code D) Java mid code 4. The command javac A) Converts a java program into binary code B) Converts a java program into bytecode C) Converts a java program into machine language D) None of the above. 5. Which of the following is not the Java primitive type A) Byte
- B) nested classes
- A) 1
- A) 1-true, 2. true, 3. true 1. All Java classes are derived from A) java.lang.Class B) java.util.Name C) java.lang.Object D) java.awt.Window 2. The jdb is used to A) Create a jar archive B) Debug a java program C) Create a C header file D) Generate java documentation 3. What would happen if “String[]args” is not included as an argument in the main method? A) No error B) Compilation error C) The program won’t run D) Program exit 4. For the execution of DELETE SQL query in JDBC, …………. method must be used. A) executeQuery() B) executeDeleteQuery() C) executeUpdate() D) executeDelete() 5. Which method will a web browser call on a new applet? A) main method B) destroy method C) execute method D) init method 6. Which of the following is not mandatory in a variable declaration? A) a semicolon B) an identifier C) an assignment D) a data type 7. When a programming class implements an interface, it must provide behavior for A) two methods defined in that interface B) any methods in a class C) only certain methods in that interface D) all methods defined in that interface 8. In order to run JSP ……………….. is required. A) Mail Server B) Applet viewer C) Java Web Server D) Database connection
9. State true or false. i) AWT is an extended version of swing ii) Paint( ) of Applet class cannot be overridden A) i-false, ii-false B) i-false,ii-true C) i-true, ii-false D) i-true, ii-true 10. Prepared Statement object in JDBC used to execute……….. queries. A) Executable B) Simple C) High level D) Parameterized Answers:
- C) java.lang.Object
- B) Debug a java program
- C) Program won’t run
- C) executeUpdate()
- D) init method
- C) an assignment
- D) all methods … interface
- C) Java Web Server
- A) i-false, ii-false
- D) Parameterized 1. In Java variables, if first increment of the variable takes place and then the assignment occurs. This operation is also called………………………… A) pre-increment B) post-increment C) incrementation D) pre incrementation 2. When the operators are having the same priority, they are evaluated from …………….. …………. in the order they appear in the expression. A) right to left B) left to right C) any of the order D) depends on the compiler 3. In Java, …………. can only test for equality, whereas ………… can evaluate any type of Boolean expression. A) switch, if B) if, switch C) if, break D) continue, if
- A) switch, if
- C) switch
- C) throws.java.io.IOException
- A) Break
- D) system
- C) Java doc
- B) Compiler 10.C) hardware 1. Preparedstatement Object in JDBC is used to execute ……………………… queries. A) executable B) simple C) high level D) parameterized 2. In JDBC …………………… imports all Java classes concerned with database connectivity. A) javax.sql.* B) java.mysql.* C) java.sql.* D) com.* 3. MS-SQL stores data in a …………………… file format. A).DAT B).MDB C).MSSQL D).OBJ 4. Ingres is a …………………… A) Socket B) Compiler C) Database D) Web server 5. In Java servlet method init( ) is called ………………… times. A) 1 B) 2 C) 0 D) multiple 6. State true or false for Java Program. i) All class variables are instance variables ii) All protected methods are friendly methods A) i-false, ii-false B) i-false, ii-true C) i-true, ii-false D) i-true, ii-true 7. State true or false for Java Program. i) Data members of an interface are by default final ii) An abstract class has implementations of all methods defined inside it. A) i-false, ii-false
B) i-false, ii-true C) i-true, ii-false D) i-true, ii-true
8. …………………… of a remotely accessible object must implement ……………. A) all methods, RemoteException B) class, RemoteException C) class, RemoteInterface D) all methods, RemoteInterface 9. ………………….is the key to …………………… A) Serialization, persistence B) Persistence, inheritance C) Inheritance, object D) Persistence, serialization 10. A method named myMethod( ) that needs two integer arguments is declared as A) public void myMethod( ); B) public void myMethod(int a, int b); C) public void myMethod(int a, b); D) public int myMethod(a, b); Answers:
- D) parameterized
- C) java.sql.*
- A).DAT
- C) Database
- A) 1
- B) i-false, ii-true
- C) i-true, ii-false
- C) class, RemoteInterface
- A) Serialization, persistence 10.B) public void myMethod(int a, int b); 1. JSP embeds in ……………. in …………………. A) Servlet, HTML B) HTML, Java C) HTML, Servlet D) Java, HTML 2. The class at the top of exception class hierarchy is …………………….. A) ArithmeticException B) Throwable C) Class D) Exception 3. In a java program, package declaration ……………….. import statements. A) must precede B) must succeed
c) Javap 3) runs java bytecode d) jdb 4) prints java code representation A) a-3, b-2,c- B) a-3, b-2, c-4, d- C) a-1, b-2, c-3, d- D) a-2, b-1, c-3, d- 10.State true or false. i) init() is called after start() in applet ii) applets are used for networking iii) inheritance is a part of Java Foundation Classes iv) final does not prevent inheritance A) i-true, ii-true, iii-false, iv-true B) i-false, ii-false, iii-false, iv-false C) i-true, ii-true, iii-true, iv-true D) i-true, ii-false, iii-false, iv-false Answers:
- D) Java, HTML
- B) Throwable
- A) must precede
- B) java.lang
- D) java.lang
- A) i-false, ii-false
- A) i-false, ii-false
- C) The code will compile correctly and will print “In first main()” (without quotes) .. run
- B) a-3, b-2, c-4, d- 10.B) i-false, ii-false, iii-false, iv-false 1. The ……………… and ……………….. classes are abstract classes that support reading and writing of byte streams. A) reader, writer B) inputstream, outputstream C) objectinputstream, objectoutputstream D) none 2. What is the error in the following code? class Test { abstract void display( ); } A) No error B) Method display( ) should be declared as static C) Test class should be declared as abstract D) Test class should be declared as public
3. A package is a collection of A) classes B) interfaces C) editing tools D) classes and interfaces 4. Which of the following methods belong to the string class? A) length( ) B) compare To ( ) C) equals ( ) D) All of them 5. What will be the output of the following code? byte x=64, y; y= (byte) (x<<2); System.out.println(y); A) 0 B) 1 C) 2 D) 64 6. If m and n are int type variables, what will be the result of the expression m%n when m=5 and n=2? A) 0 B) 1 C) 2 D) None of the above 7. Which of the following control expressions are valid for an if statement? A) An integer expression B) A Boolean expression C) Either A or B D) Neither A nor B 8. The concept of multiple inheritances is implemented in Java by A) extending two or more classes B) extending one class and implementing one or more interfaces C) implementing two or more interfaces D) both B and C 9. Which of the following do not represent legal flow control statements? A) break; B) return; C) exit(); D) continue outer; 10. Data input is A) an abstract class defined in java.io
B) i-true, ii-false, iii-true, iv-false C) i-false, ii-true, iii-false, iv-false D) i-true, ii-false, iii-false, iv-true
4. In Java, a string is a …………. A) primitive data type B) abstract data type C) combination of boolean D) None of the above 5. Methods can be overloaded with a difference only in the type of the return value. A) Not supported B) False C) True D) None of the above 6. Each method in a java class must have a unique name. A) Not necessary B) True C) False D) None of the above 7. State true or false. i) comparisons precede logical operations in java
ii) assignment operations succeed increment operations iii) arithmetic operations succeed comparisons iv) x precede + A) i-true, ii-true, iii-false, iv-true B) i-true, ii-false, iii-true, iv-false C) i-false, ii-true, iii-false, iv-false D) i-true, ii-false, iii-false, iv-true
8. It is an important feature of java that it always provides a default constructor to a class. A) Not supported B) False C) True D) None of the above 9. ………………….. is the key to ……………… A) Serialization, persistence B) Persistence, inheritance C) Inheritance, object D) Persistence, serialization 10. State true or false. i) The public can only be assigned to class
2. Java programs perform I/O through ……….. A) I/O methods B) I/O package C) streams D) compiler 3. What is the 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 Java source file D) It is the code written within the instance methods of a class
- Which of the following statements about abstract methods/classes in Java is true? A) An abstract class cannot be instantiated. B) Constructors can be abstract. C) A subclass of an abstract class must define the abstract methods. D) Static methods may be declared abstract.
- Which of the following statement is false? A) The sleep() method should be enclosed in try ……… catch block B) The yield() method should be enclosed in try ……… catch block. C) A thread can be temporarily suspended from running by using the wait() method.
D) A suspended thread using suspend() method can be revived using the resume() method.
- The new operator dynamically allocates …………..for an object and returns a reference to it. A) classes B) variables C) memory D) none of the above
- Which of the following statements correctly describes an interface? A) It’s a concrete class B) It’s a superclass C) It’s a type of abstract class D) It’s a subclass
- What is the priority of the Garbage collector thread of JDK? A) Low Priority B) Highest Priority C) Medium Priority D) Decided at run time
- ……………. is a feature that allows one interface to be used for a general class of actions.
- Which of the following statement is false? B) The yield() method should be enclosed in try ……… catch block.
- The new operator dynamically allocates …………..for an object and returns a reference to it. C) memory
- Which of the following statements correctly describes an interface? C) It’s a type of abstract class
- What is the priority of the Garbage collector thread of JDK? A) Low Priority
- ……………. is a feature that allows one interface to be used for a general class of actions. C) Polymorphism
- The default package that is implicitly called in a java program is …………. A) java. Lang
JAVA Objective Type Questions pdf free download::
- Java was developed by the company A) Sun Microsystems An image representing Sun Microsystems as depict… Sun Microsystems Image CrunchBase B) Microsoft C) Micro-tech
D) IBM
- What is the file extension of a compiled java program? A) .class B) .java C) .css D) .html
- ……………… keyword is used to invoke the current object. A) New B) That C) This D) Me
- Which of the function is used to convert string to Number in java program? A) to Number() B) conString() C) valueOf() D) toString()
- What are the part in executing a Java program and their purposes? A) Java Compiler