0

programming languages Online Quiz - 176

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

From the available options, what is the likely outcome from running the code below? (Choose one.) protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { RequestDispatcher dispatcher = getServletContext().getNamedDispatcher("/ServletB"); dispatcher.forward(request, response); }

  1. DispatcherNotFoundException.

  2. Runtime error because of incorrectly formed parameter to getNamedDispatcher() method.

  3. NullPointerException.

  4. ServletB can obtain request attribute javax.servlet.forward.request_uri.


Correct Option: C

package simplejava; public class TestMain { TestMain() { System.out.println("I am in Constructor"); } TestMain(String message) { System.out.println("Message " + message); } public static void main(String[] args) { TestMain tm = new TestMain(); } public static void main(String args) { TestMain tm = new TestMain("Hello"); } }

  1. Compiler Error

  2. I am in Constructor

  3. Message Hello

  4. Exception


Correct Option: B

package simplejava; public class TestMain1 { TestMain1() { System.out.println("I am in Constructor"); } TestMain1(String message) { System.out.println("Message " + message); } public void main(String[] args) { TestMain1 nm = new TestMain1(); TestMain1 nm1 = new TestMain1("Hello"); } }

  1. Exception

  2. Compiler Error

  3. I am in Constructor

  4. Message Hello


Correct Option: A

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) Exception - This option is incorrect because there is no exception mentioned or thrown in the code.

Option B) Compiler Error - This option is incorrect because the code does not contain any compilation errors.

Option C) I am in Constructor - This option is correct because when the TestMain1 object nm is created using the default constructor TestMain1(), the message "I am in Constructor" will be printed.

Option D) Message Hello - This option is correct because when the TestMain1 object nm1 is created using the constructor TestMain1(String message) with the argument "Hello", the message "Message Hello" will be printed.

The correct answer is C. I am in Constructor. This option is correct because the code will print "I am in Constructor" when the TestMain1 object nm is created using the default constructor.

package simplejava; public class TestConstructor1 { int p; TestConstructor1() { System.out.println("I am in Constructor"); } TestConstructor1(int p) { this.p =p; System.out.println("p = "+p); this(); } public static void main(String[] args) { TestConstructor1 tp1 = new TestConstructor1(10); } }

  1. Exception

  2. Compiler Error

  3. p = 0

  4. p=10


Correct Option: B

package simplejava; public class TestConstructor2 { int p; TestConstructor2() { System.out.print(" I am in Constructor"); } TestConstructor2(int p) { this(); this.p = p; System.out.print(" p = " + p); } public static void main(String[] args) { TestConstructor2 tp1 = new TestConstructor2(10); } }

  1. I am in Constructor p = 10

  2. I am in Constructor p = 0

  3. Compiler Error

  4. Exception


Correct Option: A

package simplejava; public class TestConstructor { int p ; public void TestConstructor(int p) { this.p=p; } public static void main(String[] args) { TestConstructor tp = new TestConstructor(10); TestConstructor tp = new TestConstructor(); System.out.println("p = "+tp.p); } }

  1. Compiler Error

  2. Exception

  3. p = 0

  4. p=10


Correct Option: A

1) Maximum length of entity name for table space?

  1. 5

  2. 4

  3. 7

  4. 8


Correct Option: D

2) Expand ROW

  1. A) Row of lock

  2. B) Row of locking

  3. C) Row level lock

  4. D) Row level locking


Correct Option: D

3) ORDER BY in Default arranged in

  1. A) Descending order

  2. B) Ascending order

  3. C) None

  4. D) Any order


Correct Option: B

4) The output of the function MIN(scalar) is

  1. A) Returns the minimum value in a set of column values

  2. B) Returns the minimum value in a set of row values

  3. C) Returns the minimum value in a set of values

  4. D) None


Correct Option: C

5) RESTRICT Operator is also known as

  1. A) PROJECT Operator

  2. B) SELECT Operator

  3. C) DIFFERENCE Operator

  4. D) INTERSECTION Operator


Correct Option: B

________ is the physical aspect of the computer that can be seen.

  1. Hardware

  2. Software

  3. Operating system

  4. Application program


Correct Option: A

AI Explanation

To answer this question, you need to understand the basic components of a computer system.

Option A) Hardware - This option is correct. Hardware refers to the physical components of a computer that can be seen and touched, such as the monitor, keyboard, mouse, hard drive, and motherboard. These components are responsible for executing the instructions provided by the software.

Option B) Software - This option is incorrect. Software refers to the programs, applications, and data that are stored on and executed by the computer's hardware. It is not the physical aspect of the computer that can be seen.

Option C) Operating system - This option is incorrect. An operating system is a software that manages computer hardware and software resources and provides common services for computer programs. It is not the physical aspect of the computer.

Option D) Application program - This option is incorrect. An application program, also known as software application or simply app, is a computer program designed to perform specific tasks or functions for the user. It is not the physical aspect of the computer.

The correct answer is A) Hardware. This option is correct because hardware refers to the physical components of a computer that can be seen.

________ is the physical aspect of the computer that can be seen.

  1. Hardware

  2. Software

  3. Operating system

  4. Application program


Correct Option: A

__________ is the brain of a computer

  1. Hardware

  2. CPU

  3. Memory

  4. Disk


Correct Option: B

Why do computers use zeros and ones?

  1. because combinations of zeros and ones can represent any numbers and characters.

  2. because digital devices have two stable states and it is natural to use one state for 0 and the other for 1.

  3. because binary numbers are simplest

  4. because binary numbers are the bases upon which all other number systems are built.


Correct Option: B

AI Explanation

To answer this question, you need to understand the concept of binary representation and how computers process information.

Option A) because combinations of zeros and ones can represent any numbers and characters. This option is incorrect. While it is true that combinations of zeros and ones can represent numbers and characters, this is not the primary reason why computers use binary representation.

Option B) because digital devices have two stable states and it is natural to use one state for 0 and the other for 1. This option is correct. Digital devices, such as transistors, have two stable states: on and off. It is natural to use one state to represent 0 and the other state to represent 1. By using binary representation, computers can easily represent and process information using these two states.

Option C) because binary numbers are simplest. This option is not entirely accurate. While binary numbers are simpler in terms of representation, their simplicity is not the main reason why computers use zeros and ones. The primary reason is the two stable states of digital devices.

Option D) because binary numbers are the bases upon which all other number systems are built. This option is not entirely accurate. While it is true that binary numbers are the foundation of all other number systems, this is not the primary reason why computers use zeros and ones. The main reason is the two stable states of digital devices.

The correct answer is B) because digital devices have two stable states, and it is natural to use one state for 0 and the other for 1. This binary representation allows computers to process information efficiently using the on/off states of digital devices.

One byte has ________ bits.

  1. 4

  2. 8

  3. 16

  4. 12


Correct Option: B

____________ is a device to connect a computer to a local area network (LAN).

  1. regular modem

  2. DSL

  3. Cable modem

  4. NIC


Correct Option: B

__________ represents an entity in the real world that can be distinctly identified.

  1. A class

  2. An object

  3. A method

  4. A data field


Correct Option: B

_______ is a construct that defines objects of the same type.

  1. A class

  2. An object

  3. A method

  4. A data field


Correct Option: A

An object is an instance of a __________.

  1. program

  2. class

  3. method

  4. data


Correct Option: B
- Hide questions