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
Questions
Choose the components of Java Platform
- JVM
- JDK
- Java API
- JRE
What data type should be used for storing precise values ?
- float
- Float
- Double
- BigDecimal
arraycopy is to copy one array into another.
- True
- False
Which of the following are true about nested class ?
- Nested class is a way of logically grouping classes that are only used in one place.
- A static nested class can refer directly to instance variables or methods defined in its enclosing class.
- Nested classes can lead to more readable and maintainable code.
- A static nested class interacts with the instance members of its outer class.
java.lang.String class is declared as a final class.
- True
- False
Choose the methods that are not available in StringBuilder class.
- length
- size
- capacity
- reverse
Java packages are to be hierarchical.
- 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.
- True
- False
To declare a bounded type parameter, which keyword is used ?
- implements
- use
- extends
- extend
Choose the one which is not a branching statement in Java.
- return
- break
- goto
- continue
Which of the below statement is True?
- Python is faster than C
- Python is faster than C++
- Python is slower than C
- None of the above
What will be the answer of a,b,c,d after the following statement? a = 2 b = 3 c = 4 d = a + + b + + + c
- a=2, b=3, c=4, d=9
- a=3, b=5,c=4, d=9
- a=3, b=4,c=4, d=11
- Error
What is the value of a? b = 3 a = b == 3 print a
- Not assigned yet
- 3
- 1
- True
What is the value of a? b = 3 a = b == 3 print a
- Not assigned yet
- 3
- 1
- True
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()
- Error
- Hello 1
- Hi 3
- Hello 3
What will be the output? class A: def __foo(self): print "Test" a = A() a.__foo()
- Test
- Syntax error
- Value error
- Attribute error
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.
- /WEB-INF
- /appserverInstallDirectory/webapps/webappName/WEB-INF/xml
- /appserverInstallDirectory/webapps/webappName/WEB-INF
- /appserverInstallDirectory/webapps/webappName/WEB-INF/classes
Identify which of the following are true statements about web applications
- The only way to access resources under the /WEB-INF directory is through appropriate servlet mapping directives in the deployment descriptor
- Server-side code has access to all resources in the web application
- Clients of web applications can't directly access resources in /WEB-INF/tld.
- A good place to keep a .tld (tag library file) is directly in the /WEB-INF directory.
Which of the following are true statements about the deployment descriptor for a web application?
- At least one <servlet> element must be present.
- <welcome-file> is a child element of <welcome-file-list>.
- <web-application> is the root element
- <servlet> elements must all be declared before <servlet-mapping> elements.
- At least one element must be present.
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 }
- The code will not compile.
- A RuntimeException will occur at lines 15/16
- An IOException will occur at line 18
- The string "Password=WebCert" will be returned to the requester
- A, B, and C above
- A, B, C, and D above.