0

programming languages Online Quiz - 280

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

Choose the components of Java Platform

  1. JVM

  2. JDK

  3. Java API

  4. JRE


Correct Option: A,C

What data type should be used for storing precise values ?

  1. float

  2. Float

  3. Double

  4. BigDecimal


Correct Option: D

arraycopy is to copy one array into another.

  1. True

  2. False


Correct Option: A
  1. Nested class is a way of logically grouping classes that are only used in one place.

  2. A static nested class can refer directly to instance variables or methods defined in its enclosing class.

  3. Nested classes can lead to more readable and maintainable code.

  4. A static nested class interacts with the instance members of its outer class.


Correct Option: A,C,D

Choose the methods that are not available in StringBuilder class.

  1. length

  2. size

  3. capacity

  4. reverse


Correct Option: B

Java packages are to be hierarchical.

  1. True

  2. False


Correct Option: B

To declare a bounded type parameter, which keyword is used ?

  1. implements

  2. use

  3. extends

  4. extend


Correct Option: C

Choose the one which is not a branching statement in Java.

  1. return

  2. break

  3. goto

  4. continue


Correct Option: C

Which of the below statement is True?

  1. Python is faster than C

  2. Python is faster than C++

  3. Python is slower than C

  4. None of the above


Correct Option: C

AI Explanation

To answer this question, we need to understand the performance differences between Python, C, and C++.

Option A) Python is faster than C - This option is incorrect because Python is generally slower than C. Python is an interpreted language, which means that it is executed line-by-line at runtime, whereas C is a compiled language that is translated into machine code before execution. This compilation process gives C a performance advantage over Python.

Option B) Python is faster than C++ - This option is incorrect because Python is generally slower than C++. Similar to C, C++ is a compiled language that can be optimized for performance. Python, on the other hand, has a higher level of abstraction and additional features that can impact performance.

Option C) Python is slower than C - This option is correct. As mentioned earlier, Python is generally slower than C due to its interpreted nature. However, it is important to note that Python provides high-level abstractions and a large standard library, which can make it more convenient and productive for certain tasks, even if it sacrifices some performance.

Option D) None of the above - This option is incorrect because option C, "Python is slower than C," is the correct answer.

The correct answer is C) Python is slower than C, as Python is generally slower due to its interpreted nature.

What will be the answer of a,b,c,d after the following statement? a = 2 b = 3 c = 4 d = a + + b + + + c

  1. a=2, b=3, c=4, d=9

  2. a=3, b=5,c=4, d=9

  3. a=3, b=4,c=4, d=11

  4. Error


Correct Option: A

What is the value of a? b = 3 a = b == 3 print a

  1. Not assigned yet

  2. 3

  3. 1

  4. True


Correct Option: D

Consider the following code snippet: class A: a = 1 def foo(self): print "Hello",self.a class B(A): a = 3 def foo(self): print "Hi",self.a A = B a = A() b = B() What is the value of a.foo()

  1. Error

  2. Hello 1

  3. Hi 3

  4. Hello 3


Correct Option: C

What will be the output? class A: def foo(self): print "Test" a = A() a.foo()

  1. Test

  2. Syntax error

  3. Value error

  4. Attribute error


Correct Option: D

Which of the following directories are legal locations for the deployment descriptor file? Note that all paths are shown as from the root of the machine or drive.

  1. /WEB-INF

  2. /appserverInstallDirectory/webapps/webappName/WEB-INF/xml

  3. /appserverInstallDirectory/webapps/webappName/WEB-INF

  4. /appserverInstallDirectory/webapps/webappName/WEB-INF/classes


Correct Option: A,C

AI Explanation

To answer this question, we need to understand the purpose and location of the deployment descriptor file in web applications.

The deployment descriptor file, also known as web.xml, is an XML file that provides configuration information for the web application. It contains details such as the servlets, filters, and URL mappings.

Now let's go through each option to understand why it is correct or incorrect:

Option A) /WEB-INF - This option is correct because the deployment descriptor file is typically located in the WEB-INF directory of a web application. This directory is not accessible directly from the web browser, making it a suitable location for sensitive configuration files.

Option B) /appserverInstallDirectory/webapps/webappName/WEB-INF/xml - This option is incorrect because the deployment descriptor file is not typically located in a subdirectory named "xml" inside the WEB-INF directory. The deployment descriptor file is directly placed in the WEB-INF directory itself.

Option C) /appserverInstallDirectory/webapps/webappName/WEB-INF - This option is correct because it correctly identifies the location of the deployment descriptor file. The WEB-INF directory is a standard location for the deployment descriptor file in web applications.

Option D) /appserverInstallDirectory/webapps/webappName/WEB-INF/classes - This option is incorrect because the "classes" directory is not the correct location for the deployment descriptor file. The "classes" directory is typically used for storing compiled Java classes, not configuration files.

Therefore, the correct answer is Option A and Option C. These options correctly identify the legal locations for the deployment descriptor file.

Identify which of the following are true statements about web applications

  1. The only way to access resources under the /WEB-INF directory is through appropriate servlet mapping directives in the deployment descriptor

  2. Server-side code has access to all resources in the web application

  3. Clients of web applications can't directly access resources in /WEB-INF/tld.

  4. A good place to keep a .tld (tag library file) is directly in the /WEB-INF directory.


Correct Option: B,C,D

AI Explanation

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

Option A) The statement says that the only way to access resources under the /WEB-INF directory is through appropriate servlet mapping directives in the deployment descriptor. This statement is incorrect. The /WEB-INF directory is not accessible to clients directly, but server-side code can access resources in this directory without the need for servlet mapping directives.

Option B) The statement says that server-side code has access to all resources in the web application. This statement is correct. Server-side code, such as servlets or JSPs, has access to all resources within the web application, including files in the /WEB-INF directory.

Option C) The statement says that clients of web applications can't directly access resources in /WEB-INF/tld. This statement is correct. The /WEB-INF directory and its subdirectories are not directly accessible to clients. Therefore, clients cannot directly access resources in /WEB-INF/tld.

Option D) The statement says that a good place to keep a .tld (tag library file) is directly in the /WEB-INF directory. This statement is correct. The /WEB-INF directory is commonly used to store configuration files, including tag library descriptor files (.tld).

To summarize:

Option A) Incorrect - The /WEB-INF directory can be accessed by server-side code without servlet mapping directives. Option B) Correct - Server-side code has access to all resources in the web application. Option C) Correct - Clients cannot directly access resources in /WEB-INF/tld. Option D) Correct - The /WEB-INF directory is a good place to keep a .tld file.

The correct answer is B, C, and D.

Which of the following are true statements about the deployment descriptor for a web application?

  1. At least one element must be present.

  2. is a child element of .

  3. is the root element

  4. elements must all be declared before elements.

  5. At least one element must be present.


Correct Option: B,E

Assume that there is a file called secure.txt, located at /WEB-INF/securefiles, whose contents are "Password=WebCert." What statements are false about the result of compiling and running the following code? 11 public class CodeTestServlet extends HttpServlet { 12 protected void doGet(HttpServletRequest request, 13 HttpServletResponse response) throws IOException { 14 ServletContext sc = getServletContext(); 15 InputStream is = sc.getResourceAsStream("/WEB-" + 16 "INF/securefiles/secure.txt"); 17 BufferedReader br = new BufferedReader(new InputStreamReader(is)); 18 System.out.println(br.readLine()); 19 } 20 }

  1. The code will not compile.

  2. A RuntimeException will occur at lines 15/16

  3. An IOException will occur at line 18

  4. The string "Password=WebCert" will be returned to the requester

  5. A, B, and C above

  6. A, B, C, and D above.


Correct Option: F
- Hide questions