intTypePromotion=1
zunia.vn Tuyển sinh 2024 dành cho Gen-Z zunia.vn zunia.vn
ADSENSE

Java Practice 1

Chia sẻ: Hồ đông Nhựt | Ngày: | Loại File: DOC | Số trang:13

166
lượt xem
45
download
 
  Download Vui lòng tải xuống để xem tài liệu đầy đủ

Tham khảo tài liệu 'java practice 1', công nghệ thông tin, kỹ thuật lập trình phục vụ nhu cầu học tập, nghiên cứu và làm việc hiệu quả

Chủ đề:
Lưu

Nội dung Text: Java Practice 1

  1. 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
  2. 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
  3. 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
  4. 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
  5. 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
  6. 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()
  7. 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
  8. 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? A.True B.False
  9. 9 . State true or false :- Final variables should be declared in the beginning? A.True B.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 of the following is not a 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.
  10. A.1, 2 B.2, 3 C.1, 2, 3 D.1, 3 16 . Fill in the blanks :- System class provides access to the _______________ resources. A.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 methods are methods of the Math class? A.absolute( ) B.log( ) C.cosine( ) D.sine( ) 20 . 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.
  11. D.Both classes implement 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. 23 . State true or false :- The File class contains a method that changes the current working directory. A.True B.False 24 . Which of the following are true about the File class? (Select multiple) A.File objects can be garbage collected. B.A File object can be used to access the files in the current directory. C.When a File object is created, a corresponding directory or file is created in the local file system. D.File objects are used to access files and directories on the local file system. 25 . 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.
  12. 26 . Which of the following can you perform using the File class? (Select multiple) A.Change the current directory B.Return the name of the parent directory C.Delete a file D.Find if a file contains text or binary information 27 . What is true regarding the uses of servlets A.A servlet can handle multiple requests concurrently, and can synchronize requests. This allows servlets to support systems such as on-line conferencing. B.Servlets can forward requests to other servers and servlets. C.Servlets can be used to balance load among several servers that mirror the same content, and to partition a single logical service over several servers, according to task type or organizational boundaries. D.All of the above. 28 . What is the legal range of a byte integral type? A.0 - 65, 535 B.(-128) - 127 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 D.Does not compile E.Compiles but generates a compile time error 30 . Which of the following are correct?
  13. A.128 >> 1 gives 64 B.128 >>> 1 gives 64 C.128 >> 1 gives -64 D.128 >>> 1 gives -64
ADSENSE

CÓ THỂ BẠN MUỐN DOWNLOAD

 

Đồng bộ tài khoản
2=>2