Java Practice 1 pdf

16 330 0
Java Practice 1 pdf

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

Java Practice 1 1. The data defined by the class are referred to as member variables or instance variables A. True B. False 2 . What a Java programmer calls a __________ , a C/C++ programmer calls a function A. Classes B. Method C. Function D. Object 3 . Each method or variable in a class may be marked private or public A. True B. False 4 . _____________ is the process by which one object acquires the properties of another object A. Encapsulation B. Class C. Inheritence D. Polymorphism 5 . _________ is a feature that allows one interface to be used for a general class of actions. A. Encapsulation B. Class C. Inheritence D. Polymorphism 6 . In Java, a source file is officially called a compilation unit. A. True B. False 7 . The Java compiler requires that a source file use the ________ filename extension A. .h B. . java C. >java D. .class 8 . When Java source code is compiled, each individual class is put into its own output file named after the class and using the ______ extension A. .h B. . java C. >java D. .class 9 . Comments in Java Program must begin with /* and end with */ A. True B. False 10 . All statements in Java end with a _____________ A. Colon B. SemiColon C. Hypen D. Dot 11 . The simplest form of the for loop in Java is for(initialization; condition; iteration) statement; A. True B. False 12 . Java allows two or more statements to be grouped into blocks of code called Code Blocks A. True B. False 13 . You do not need to follow any special indentation rules in Java A. True B. False 14 . Java is Case ________ A. Insensitive B. Sensitive 15 . A constant value in Java is created by using a literal representation of it A. True B. False 16 . The keywords const and goto are reserved but not used A. True B. False 17 . The Separator [ ] is Used to declare array types A. True B. False 18 . enum is a Keyword in Java, introduced from J2SE 5 A. True B. False 19 . Java's built-in methods are members of the System class, which is a class predefined by Java that is automatically included in your programs A. True B. False 20 . The print( ) method is just like println( ), except that it does not output a newline character after each call A. True B. False 1 . The Java interpreter is used for the execution of the source code. A. True B. False 2 . On successful compilation a file with the .exe extension is created. A. True B. False 3 . The Java source code can be created in a Notepad editor. A. True B. False 4 . The Java Program is enclosed in a class definition. A. True B. False 5 . Class and main() methods declarations are required for every Java application? A. True B. False 6 . Java Compiler and Java Interpreter are the two parts in executing a Java program. A. True B. False 7 . Encapsulation, Inheritance and Polymorphism are the three OOPs principles. A. True B. False 8 . Java source code file is a compilation unit. A. True B. False 9 . What output is displayed as the result of executing the following statement? System.out.println("// Looks like a comment."); // Looks like a comment A. Looks like a comment B. The statement results in a compilation error C. No output is displayed 10 . 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 11 . Void is the return type of program's main( ) method. A. True B. False 12 . string array is the argument type of program's main( ) method. A. True B. False 13 . __________ will be automatically invoked when an object is created. A. Method B. Constructor C. Function 14 . method has to be call explicitly. A. True B. False 15 . loading the driver and making the connection are the steps involved in establishing a connection of JDBC. A. True B. False 16 . In JDBC ______________ used to create an instance of a driver and register it with the DriverManager. When you have loaded a driver, it is available for making a connection with a DBMS. A. Class.forDriver B. Class.forData C. Class.forName 17 . DriverManager.getConnection function establishes a connection to call the appropriate driver connected to the DBMS. A. True B. False 18 . CallableStatement object is used to call a Strored Procedure from JDBC. A. True B. False 19 . One of the new features in the JDBC 2.0 API is the ability to move a result set's cursor Backward as well as Forward. A. True B. False 20 . javax.servlet and javax.servlet.http are the two packages for servlets A. True B. False 21 . In the Life cycle of a servlet init() method initates the servlet and destroy() method destroys the servlet. A. True B. False 22 . The servlet handles the client request through service() method. A. True B. False 23 . ServletContext() interface gives access to information about the environment and allows them to log significant events. A. True B. False 24 . _________ method is used for getting information. A. doMake() B. doGet() C. Get() 25 . _________ method for posting the information A. doResponse() B. doPost() C. Post() 26 . Genereic servlet and Httpservlets are the different types of servlets. A. True B. False 27 . Web Server loads the init() method of servlet. A. True B. False 28 . If you want to modify the servlet, The webserver need to be shutdown. A. True B. False 29 . Server-Side Includes(SSI) allows embedding servlets within HTML pages using a special servlet tag. A. True B. False 30 . When we compare session and URLREWriting there is need for maintaining data in URLREWriting but where as in the Session it will maintain only the session id. A. True B. False 1 . Fill in the blanks :- The main subclass of the Exception class is _______ class. A. RuntimeException B. NumberFormatException 2 . Fill in the blanks :- Only subclasses of ______class may be caught or thrown. A. Throwable B. Throws 3 . Fill in the blanks :- Any user-defined exception class is a subclass of the _____ class. A. Exception B. Throws C. Throwable 4 . How do you achieve multiple inheritance in Java? A. Using interfaces. B. Using abstract classes C. Using final classes D. None of the above 5 . Name interfaces without a method? (Select multiple) A. Serializable B. Cloneble C. Remote D. UserDefined 6 . What are the advantages of inheritance? (Select multiple) A. Reusability of code B. accessibility of variables of the superclass by subclasses. C. Accessibility of methods of the superclass by subclasses. D. a,b are true 7 . State true or false :- Final methods can be overridden. A. True B. False 8 . State true or false :- Declaration of methods as final results in faster execution of the program? [...]... out The age is 1 C Compiles but generates a runtime error D Does not compile E Compiles but generates a compile time error 30 Which of the following are correct? A 12 8 >> 1 gives 64 B 12 8 >>> 1 gives 64 C 12 8 >> 1 gives -64 D 12 8 >>> 1 gives -64 ... wrapper class? A String B Integer C Boolean D Character 14 Which of the following methods cause the String object referenced by s to be changed? (Select multiple) A s.concat( ) B s.toUpperCase( ) C s.replace( ) D s.valueOf( ) 15 What are the constants defined by Byte, Short, Integer and Long? 1 MAX_VALUE, 2 MIN_VALUE 3 TYPE A 1, 2 B 2, 3 C 1, 2, 3 D 1, 3 16 Fill in the blanks :- System class provides access... False 10 State true or false :- Can we declare variable inside a method as final variables? A True B False 11 An interface contains methods A Non-abstract B Implemented C unimplemented 12 What is the use of valueOf( ) method? A It converts data from its internal format into a human-readable form B It converts integer value to string C It converts string to int value D None of the above 13 Which... byte integral type? A 0 - 65, 535 B ( -12 8) - 12 7 C (-32,768) - 32,767 D (-256) - 255 29 What will be the result of compiling the following code: public class Test { static int age; public static void main (String args []) { age = age + 1; System.out.println("The age is " + age); } } A Compiles and runs with no output B Compiles and runs printing out The age is 1 C Compiles but generates a runtime error... Data B System C Util 17 Which of the following classes is used to perform basic console I/O? A System B SecurityManager C Math D Runtime 18 Which of the following are true? (Select multiple) A The Class class is the superclass of the Object class B The Object class is final C The Class class can be used to load other classes D The ClassLoader class can be used to load other classes 19 Which of the following... Throwable 21 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 22 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 . error 30 . Which of the following are correct? A. 12 8 >> 1 gives 64 B. 12 8 >>> 1 gives 64 C. 12 8 >> 1 gives -64 D. 12 8 >>> 1 gives -64 . s.replace( ) D. s.valueOf( ) 15 . What are the constants defined by Byte, Short, Integer and Long? 1. MAX_VALUE, 2. MIN_VALUE 3. TYPE. A. 1, 2 B. 2, 3 C. 1, 2, 3 D. 1, 3 16 . Fill in the blanks :-. rules in Java A. True B. False 14 . Java is Case ________ A. Insensitive B. Sensitive 15 . A constant value in Java is created by using a literal representation of it A. True B. False 16 . The

Ngày đăng: 08/07/2014, 08:21

Từ khóa liên quan

Tài liệu cùng người dùng

Tài liệu liên quan