0

programming languages Online Quiz - 177

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

package loop; public class TestLoop2 { public static void main(String[] args) { int p = 100; do { while(p>100) { System.out.println("I am in while"); } System.out.println("I am in do-while"); } while (p > 100); } }

  1. I am in do-while

  2. I am in while I am in do-while

  3. Compiler Error

  4. No output


Correct Option: A

package loop; public class TestLoop6 { void testFor() { for (int i = 1; i < 10; i++) { System.out.println("i in for loop = " + i); if (i == 1) { return; } } System.out.println("For loop over"); } public static void main(String[] args) { TestLoop6 tl = new TestLoop6(); tl.testFor(); System.out.println("Method call over"); } }

  1. i in for loop = 1 For loop over Method call over

  2. i in for loop = 1 Method call over

  3. Compiler Error

  4. Exception


Correct Option: B

package loop; public class TestLoop1 { void testFor() { for (int i = 1; i < 3; i++) { System.out.println("i in for loop = " + i); if (i == 1) { break; } } System.out.println("For loop over"); } public static void main(String[] args) { TestLoop1 tl = new TestLoop1(); tl.testFor(); System.out.println("Method call Over"); } }

  1. i in for loop = 1 i in for loop = 2 For loop over Method call Over

  2. i in for loop = 1 For loop over Method call Over

  3. Compiler Error

  4. i in for loop = 1 Method call Over


Correct Option: B

package overriding; class Super3 { void testDivide(int i, int j) throws Exception { double p = i / j; System.out.println("p in Super =" + p); } } public class TestOverrideSub3 extends Super3 { void testDivide(int i, int j) throws ArithmeticException { double p = i / j; System.out.println("p in Sub =" + p); } public static void main(String[] args) { Super3 s3 = new TestOverrideSub3(); try { s3.testDivide(10, 5); } catch (Exception e) { System.out.println("Exception " + e.getMessage()); } } }

  1. p in Super =2.0

  2. p in Sub =2.0

  3. Compiler error

  4. Exception


Correct Option: B

package overriding; class Super2 { void testSuper(int empId) { System.out.println("I am in Super " + empId); } } public class TestOverrideSub2 extends Super2 { public void testSuper(int empId) { System.out.println("I am in Sub " + empId); } public static void main(String[] args) { Super2 s2 = new TestOverrideSub2(); s2.testSuper(144670); } }

  1. I am in Sub 144670

  2. I am in Super 144670

  3. Compiler error

  4. Exception


Correct Option: A

package overriding; class Super4 { final void testSuper() { System.out.println("I am Super"); } } public class TestOverrideSub4 extends Super4{ void testSuper() { System.out.println("I am Sub"); } public static void main(String[] args) { Super4 s4 = new TestOverrideSub4(); s4.testSuper(); } }

  1. Compiler Error

  2. I am Sub

  3. I am Super

  4. Exception


Correct Option: A

package overriding; class Super5 { int testAdd(int x,int y) { System.out.println("Super Add "+(x+y)); return(x+y); } } public class TestOverrideSub5 extends Super5{ long testAdd(int x,int y) { System.out.println("Sub Add "+(x+y)); return(x+y); } public static void main(String[] args) { Super5 s5 = new TestOverrideSub5(); s5.testAdd(5,5); } }

  1. Compiler Error

  2. Exception

  3. Sub Add 10

  4. Super Add 10


Correct Option: A
  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
  1. getInitParameterNames()

  2. getInitParameter(String name)

  3. getServletName()

  4. getServletContext()


Correct Option: B
  1. META-INF is a suitable location for storing digital certificates.

  2. META-INF is used as a repository for common code.

  3. The MANIFEST.MF file is found in the META-INF directory.

  4. The deployment descriptor file is found in the META-INF directory.

  5. META-INF is not directly accessible to clients.


Correct Option: A,C,E

What is the result of loading the web-app with the following deployment descriptor and attempting to execute the following servlet? (Choose two.) author Elmore Leonard public class ContextInitParms extends HttpServlet { protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { response.setContentType("text/html"); PrintWriter out = response.getWriter(); Out.write(""); ServletContext sc = getServletContext(); out.write(sc.getInitParameter("auther")); out.close(); } }

  1. ParameterNotFoundException is thrown.

  2. Some other exception is thrown.

  3. "Elmore Leonard" is output on the web page

  4. An application failure occurs

  5. null is output on the web page.

  6. A 404 error occurs in the browser.


Correct Option: D,F
  1. LogFilter, AuditFilter, EncryptionFilter

  2. LogFilter, EncryptionFilter

  3. LogFilter

  4. EncryptionFilter, AuditFilter, LogFilter

  5. EncryptionFilter, LogFilter

  6. AuditFilter, EncryptionFilter, LogFilter


Correct Option: E
- Hide questions