0

programming languages Online Quiz - 68

Description: programming languages Online Quiz - 68
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

We can modify value of literals as below: char *name="David"; *name='X';

  1. True

  2. False


Correct Option: B

The expression: i++ * ++i; is not well defined.

  1. True

  2. False


Correct Option: A

Casting the return value from malloc function is necessary.

  1. True

  2. False


Correct Option: B

In the init(ServletConfig) method of Servlet life cycle, what method can be used to access the ServletConfig object ?

  1. getServletInfo()

  2. getInitParameters()

  3. getServletConfig()

  4. None


Correct Option: C

Which of the implicit objects won’t be available ?

  1. session, request

  2. exception, request

  3. exception, config

  4. session, exception


Correct Option: D

ejbCreate() method of CMP bean returns

  1. null

  2. Primary Key class

  3. Home Object

  4. Remote Object


Correct Option: A

Which of the following is correct syntax for an Abstract class ?

  1. abstract double area() { }

  2. abstract double area()

  3. abstract double area();

  4. abstract double area(); { }


Correct Option: C

What is the output of following block of program ? boolean var = false; if(var = true) { System.out.println(“TRUE”); } else { System.out.println(“FALSE”); }

  1. TRUE

  2. FALSE

  3. Compilation Error

  4. Run-time Error


Correct Option: A

What is an infinite loop?

  1. A loop that functions infinitely well

  2. A loop that runs forever

  3. A loop that never starts

  4. A loop that will never function


Correct Option: B

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

  1. True

  2. False


Correct Option: B

Which interface is implemented by the services in order to pass configuration information to a Servlet when it first starts

  1. Structs Config

  2. WebXML

  3. ServletConfig

  4. None of the above


Correct Option: C

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.

  1. Class.forName

  2. Class.JDBCODBC

  3. Class.JdbcDriver

  4. Class.Loader


Correct Option: A

_________ method for posting the information in Action class

  1. doGet()

  2. doPost()

  3. execute()

  4. validate()


Correct Option: B

Which abstract class is the super class of all classes used for writing characters. Select the one correct answer.

  1. FileWriter

  2. CharWriter

  3. Writer

  4. OutputStream

  5. FileOutputStream


Correct Option: C

__________ will be automatically invoked when an object is created.

  1. method

  2. garbage collection

  3. finalizer

  4. Constructor

  5. none of the above


Correct Option: D

AI Explanation

To answer this question, you need to understand the concept of constructors.

Option A) method - This option is incorrect because a method is a block of code that performs a specific task. It is not automatically invoked when an object is created.

Option B) garbage collection - This option is incorrect because garbage collection is the process of automatically reclaiming the memory occupied by objects that are no longer in use. It is not invoked when an object is created.

Option C) finalizer - This option is incorrect because a finalizer is a special method that is automatically called before an object is garbage collected. It is not invoked when an object is created.

Option D) Constructor - This option is correct because a constructor is a special method that is automatically invoked when an object is created. It is used to initialize the state of the object and allocate memory for it.

Option E) none of the above - This option is incorrect because option D, Constructor, is the correct answer.

The correct answer is D) Constructor. This option is correct because a constructor is automatically invoked when an object is created.

In order for a source code file, containing the public class Test, to successfully compile, which of the following must be true?

  1. It must have a package statement

  2. It must be named Test.java

  3. It must import java.lang

  4. It must declare a public class named Test


Correct Option: B

AI Explanation

To answer this question, we need to understand the requirements for compiling a source code file in Java.

Option A) It must have a package statement - This option is incorrect because a source code file can be compiled without a package statement. The package statement is used to organize classes into different packages, but it is not a requirement for compilation.

Option B) It must be named Test.java - This option is correct because Java source code files must be named with the same name as the public class they contain. In this case, the public class is named Test, so the file must be named Test.java.

Option C) It must import java.lang - This option is incorrect because the import statement for java.lang is automatically added by the Java compiler. It is not necessary to explicitly import java.lang in your source code file.

Option D) It must declare a public class named Test - This option is incorrect because it is not necessary to declare a public class named Test in order for the source code file to compile. However, if the source code file does contain a public class, it must be named Test to match the file name.

Therefore, the correct answer is B) It must be named Test.java. This option is correct because Java source code files must be named with the same name as the public class they contain.

_____________ is the mechanism that servlets use to have a client hold a small amount of state information associated with the user.

  1. sessions

  2. HttpRequest

  3. HttpResponse

  4. Java Beans

  5. Cookies


Correct Option: E

If you want to modify the servlet, The webserver need to be shutdown.

  1. True

  2. False


Correct Option: B

The following is NOT an example of a data type.

  1. int

  2. public

  3. Button

  4. void


Correct Option: B

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

  1. True

  2. False


Correct Option: B
- Hide questions