Java and Python Programming Fundamentals

Test your knowledge of Java and Python programming concepts including classes, inheritance, generics, web applications, operators, and core language features

20 Questions Published

Questions

Question 1 Multiple Choice (Multiple Answers)

Choose the components of Java Platform

  1. JVM
  2. JDK
  3. Java API
  4. JRE
Question 2 Multiple Choice (Single Answer)

What data type should be used for storing precise values ?

  1. float
  2. Float
  3. Double
  4. BigDecimal
Question 3 True/False

arraycopy is to copy one array into another.

  1. True
  2. False
Question 4 Multiple Choice (Multiple Answers)

Which of the following are true about nested class ?

  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.
Question 5 True/False

java.lang.String class is declared as a final class.

  1. True
  2. False
Question 6 Multiple Choice (Multiple Answers)

Choose the methods that are not available in StringBuilder class.

  1. length
  2. size
  3. capacity
  4. reverse
Question 7 True/False

Java packages are to be hierarchical.

  1. True
  2. False
Question 8 True/False

Type erasure is a process where the compiler removes all information related to type parameters and type arguments within a class or method.

  1. True
  2. False
Question 9 Multiple Choice (Single Answer)

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

  1. implements
  2. use
  3. extends
  4. extend
Question 10 Multiple Choice (Single Answer)

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

  1. return
  2. break
  3. goto
  4. continue
Question 11 Multiple Choice (Single Answer)

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
Question 12 Multiple Choice (Single Answer)

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
Question 13 Multiple Choice (Single Answer)

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

  1. Not assigned yet
  2. 3
  3. 1
  4. True
Question 14 Multiple Choice (Single Answer)

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

  1. Not assigned yet
  2. 3
  3. 1
  4. True
Question 15 Multiple Choice (Single Answer)

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
Question 16 Multiple Choice (Single Answer)

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
Question 17 Multiple Choice (Multiple Answers)

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
Question 18 Multiple Choice (Multiple Answers)

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.
Question 19 Multiple Choice (Multiple Answers)

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

  1. At least one <servlet> element must be present.
  2. <welcome-file> is a child element of <welcome-file-list>.
  3. <web-application> is the root element
  4. <servlet> elements must all be declared before <servlet-mapping> elements.
  5. At least one element must be present.
Question 20 Multiple Choice (Multiple Answers)

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.