Saturday, June 16, 2018

Upwork JAVA TEST V3 2018

Hello Freelancer, Get the JAVA TEST V3 of Latest version 2018. We are ready here to provide your desire upwork test answer. We already tested all exam test information Available include on here. So Dear, Why Late? Read the below full exam test and get more information from our website.

1. Which statements are true regarding ServletContext Init Parameters in the deployment descriptor?
Answers:
  1. They are set at deployment-time, but accessed at run-time.
  2. They are accessible from any session within that context.
  3. They are not set at deployment-time, but accessed at run-time.
  4. They are set at deployment-time and can be updated at run-time.
2. Which of the following symbols are metacharacters supported by the java.util.regex API?
Answers:
  1. .
  2. @
  3. #
3. SQLException has a feature of chaining – identify the right code to execute the same from the following options:
Answers:
  1. catch(SQLException e) { out.println(e.getMessage()); while((e=e.getNextException())!=null) { out.println(e.getMessage()); } }
  2. catch(SQLException e) { out.println(e.getNextException()); while((e=e.getMessage())!=null) { out.println(e.getMessage()); } }
  3. catch(SQLException e) { out.println(e.getMessage()); while((e=e.getEncapsulatedException())!=null) { out.println(e.getMessage()); } }
  4. catch(ClassNotFoundException e) { out.println(e.getMessage()); while((e=e.getNextException())!=null) { out.println(e.getMessage()); } }
  5. catch(ClassNotFoundException e){ { out.println(e.getMessage()); } }
4. What is the result of an attempt to compile and run the given program?
public class Test107 {
public static void main(String[] args) {
System.out.println(test());
}
private static int test() {
return (true ? null : 0); 
}
}
Answers:
  1. It gets a compiler error, because of an attempt to return null from the method with return type “int”.
  2. It compiles, but throws NullPointerException at run-time.
  3. It compiles, runs, and prints “null” (without quotes).
  4. It compiles, runs, and prints “0” (without quotes).
5. Which of the following methods are members of the Vector class and allow you to input a new element?
Answers:
  1. addItem
  2. append
  3. insert
  4. addElement
6. In which class is the notify method defined?
Answers:
  1. Thread
  2. Applet
  3. Runnable
  4. Object
7. What is the output of the given program?
public class Test93 {
private int x = 0;
public static void main(String[] args) {
new Test93().test();
}
private int f(int x) { return ++x; }
private int g(int y) { return x++; }
private void test() {
System.out.print( f(x)==f(x) ? “f” : “#” );
System.out.print( g(x)==g(x) ? “g” : “#” );
}
}
Answers:
  1. ##
  2. #g
  3. f#
  4. fg
8. Which design pattern reduces network traffic by acting as a caching proxy of a remote object?
Answers:
  1. DataAccess Object
  2. Model-View-Controller
  3. Value Object
  4. Business Delegate
9. What is the output of the given program?
public class Test89 {
public static void main(String[] args) {
T x = new T(“X”, null); x.start();
T y = new T(“Y”, x); y.start();
T z = new T(“Z”, y); z.start();
}
}
class T extends Thread {
private Thread predecessor;
private String name;
public T(String name, Thread predecessor) { 
this.predecessor = predecessor; 
this.name = name; 
}
public void run() {
try {
Thread.sleep((int)(Math.random()*89));
System.out.print(name);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
Answers:
  1. always XYZ
  2. always ZYX
  3. any of the following: XYZ, XZY, YXZ, YZX, ZXY, ZYX
  4. any of the following: XYZ, ZYX
10. The principal finder method that must be implemented by every entity bean class is:
Answers:
  1. findByPrimaryKey()
  2. ejbGetByPrimaryKey()
  3. ejbFindPrimayKey()
  4. getPrimaryKey()
  5. getFinder()
11. Which option lists Java access modifiers in the right order from the most permissive to the most restrictive?
Answers:
  1. public, protected, <i>no modifier/default/package</i>, private
  2. public, <i>no modifier/default/package</i>, protected, private
  3. <i>no modifier/default/package</i>, public, protected, private
  4. public, protected, private, <i>no modifier/default/package</i>
12. What should be the replacement of “//ABC” in the following code?
class Krit
{
String str= new String(“OOPS !!! JAVA”);
public void KritMethod(final int iArgs)
{
int iOne;
class Bicycle
{
public void sayHello()
{
//ABC
}
}
}
public void Method2()
{
int iTwo;
}
}
Answers:
  1. System.out.print(str);
  2. System.out.print(iOne);
  3. System.out.print(iTwo);
  4. System.out.print(iArgs);
13. Assuming that val has been defined as an int for the code below, which values of val will result in “Test C” being printed?
if( val > 4 ) {
System.out.println(“Test A”);
} else if( val > 9 ) {
System.out.println(“Test B”);
} else
System.out.println(“Test C”);
Answers:
  1. val < 0
  2. val between 0 and 4
  3. val between 4 and 9
  4. val > 9
  5. val = 0
  6. No values for val will result in “Test C” being printed.
14. What is the output of the given program?
public class Test118 extends _Test118 {
{
System.out.print(“_INIT”);
}
static {
System.out.print(“_STATIC”);
}
Test118() {
System.out.print(“_CONST”);
}
public static void main(String[] args) {
System.out.print(“_MAIN”);
new Test118();
}
}
class _Test118 {
_Test118() {
System.out.print(“_BASE”);
}
}
Answers:
  1. _STATIC_MAIN_BASE_INIT_CONST
  2. _STATIC_MAIN_INIT_BASE_CONST
  3. _INIT_STATIC_MAIN_BASE_CONST
  4. _INIT_STATIC_MAIN_BASE_CONST
15. What will be the output, if the following program is run?public class Test8 {
public static void main(String[] args) {
System.out.println(Math.sqrt(-4));
}
}
Answers:
  1. null
  2. 2
  3. NaN
  4. -2.0
16. What will be the output of this program?
public class Test {
public static void main(String args[]) {
int a, b;
a = 2;
b = 0;
System.out.println(g(a, new int[] { b }));
}
public static int g(int a, int b[]) {
b[0] = 2 * a;
return b[0];
}
}
Answers:
  1. 0
  2. 1
  3. An exception will occur
  4. 4
17. There are three classes named A, B, and C. The class B is derived from class A and class C is derived from B. Which of the following relations are correct for the given classes?
Answers:
  1. Any instance of A is an instance of B.
  2. Any instance of B is an instance of A.
  3. Any instance of C is an instance of B.
  4. Any instance of B is an instance of C.
18. What is the output of the given console application?
public class Test19 {
public static void main(String[] args) {
final int X = 9;
int[][] a = {{5, 4, 3}, {9, 7, 2}, {1, 6, 8}};
for (int i=0; i<3; i++) {
for (int j=0; j<3; j++) {
if (a[i][j] == X) break;
System.out.print(a[i][j] + “” “”);
}
}
}
}
Answers:
  1. ‘5
  2. 5 4 3
  3. 5 4 3 1 6 8
  4. 5 4 3 7 2 1 6 8
19. Which of the following statements is true?
Answers:
  1. public interface RemoteTrain extends java.rmi.Remote
  2. public class RemoteTrain extends java.rmi.Remote
  3. public interface RemoteTrain extends java.net.Remote
  4. public class RemoteTrain extends java.net.Remote
  5. private class RemoteTrain extends java.net.Remote
20. The JDK comes with a special program that generates skeleton and stub objects that is known as:
Answers:
  1. java.rmi.Remote
  2. rmi
  3. rmic
  4. rmijava
  5. javac
21. How many objects are created by the following code?
Object a, b, c, d, e;
e = new Object ();
b = a = e;
e = new Object ();
Answers:
  1. 2
  2. 5
  3. 4
  4. That code is invalid.
22. Which of these interfaces is the most applicable when creating a class that associates a set of keys with a set of values?
Answers:
  1. Collection
  2. Set
  3. Map
  4. SortedSet
23. Which of the following is the correct syntax for creating a Session object?
Answers:
  1. HttpSession ses=request.getSession(true);
  2. HttpSession ses=getSession(true);
  3. HttpSession ses=request.getSession();
  4. HttpSession ses=request.getSessionObject(true);
  5. HttpSession ses=response.getSession(true);
24. Which statement is true about the given code?
public class Test78 {
public static void main(String[] args) throws Exception {
new JBean().setHeight(1).setWidth(2).setDepth(3).setDensity(9);
}
}
class JBean {
private int height, width, depth, density;
public JBean setHeight (int h) { this.height = h; return this; }
public JBean setWidth (int w) { this.width = w; return this; }
public JBean setDepth (int d) { this.depth = d; return this; }
public JBean setDensity (int d) { this.density = d; return this; }
}
Answers:
  1. The code does not compile, because two setters have a formal parameter with the same name.
  2. The setters of the JBean class are JavaBean-compliant.
  3. The code compiles, but throws a NullPointerException at run-time.
  4. The code compiles and runs.
25. Choose all valid forms of the argument list for the FileOutputStream constructor shown below:
Answers:
  1. FileOutputStream( FileDescriptor fd )
  2. FileOutputStream( String n, boolean a )
  3. FileOutputStream( boolean a )
  4. FileOutputStream()
  5. FileOutputStream( File f )
26. Which of the following methods should be invoked by the container to get a bean back to its working state?
Answers:
  1. EJBPassivate()
  2. EJBActivate()
  3. EJBRemove()
  4. EJBOpen()
  5. EJBActivation()
27. Select all true statements:
Answers:
  1. An abstract class can have non-abstract methods.
  2. A non-abstract class can have abstract methods.
  3. If a non-abstract class implements interface, it must implement all the methods of the interface.
  4. If a non-abstract class inherits abstract methods from its abstract superclass, it must implement the inherited abstract methods.
28. Which option could be used to see additional warnings about code that mixes legacy code with code that uses generics?
Answers:
  1. -Xlint:unchecked
  2. -Xlint:-unchecked
  3. -Xswitchcheck or -Xlint:fallthrough depending on the version of Java
  4. -classpath or -cp
29. Assuming the servlet method for handling HTTPGET requests is doGet(HttpServletRequest req, HTTPServletResponse res), how can the request parameter in that servlet be retrieved?
Answers:
  1. String value=req.getInitParameter(10);
  2. String value=req.getInitParameter(“product”);
  3. String value=res.getParameter(“product”);
  4. String value=req.getParameter(“product”);
30. Which of these is not an event listener adapter defined in the java.awt.event package?
Answers:
  1. ActionAdapter
  2. MouseListener
  3. WindowAdapter
  4. FocusListener
31. What would be the result of compiling and running the following code class?
public class Test {
public static void main(String args[]) {
Test t = new Test();
t.start();
}
public void start() {
int i = 2;
int j = 3;
int x = i & j;
System.out.println(x);
}
}
Answers:
  1. The code will not compile.
  2. The code will compile but will give a runtime error.
  3. The code will compile and print 2.
  4. The code will compile and print 1.
32. Which of the following are the methods of the Thread class?
Answers:
  1. stay()
  2. go()
  3. yield()
  4. sleep(long millis)
33. What protocol is used by the DatagramSocket class?
Answers:
  1. STCP
  2. UDP
  3. TCP
  4. FTP
  5. None of the above
34. Which statements are true? Select all true statements.
Answers:
  1. A member variable can be declared synchronized.
  2. A class can be declared transient.
  3. A class be declared synchronized.
  4. A method can be declared synchronized.
35. Which exception must a setter of a constrained JavaBean property throw to prevent the property value from changing?
Answers:
  1. PropertyVetoException
  2. IllegalArgumentException
  3. IllegalComponentStateException
  4. InvalidAttributeValueException
36. X.509 version 3 specifies which of the following?
Answers:
  1. A format and content for digital certificates.
  2. The IPSec standard.
  3. The Secure Socket Layer.
  4. The Data Encryption Standard.
  5. A file for digital certificates.
37. What will be the output when this code is compiled and run?
public class Test {
public Test() {
Bar b = new Bar();
Bar b1 = new Bar();
update(b);
update(b1);
b1 = b;
update(b);
update(b1);
}
private void update(Bar bar) {
bar.x = 20;
System.out.println(bar.x);
}
public static void main(String args[]) {
new Test();
}
private class Bar {
int x = 10;
}
}
Answers:
  1. The code will fail to compile.
  2. 10 10 10 10
  3. 20 20 20 20
  4. 10 20 10 20
38. Which of the following methods can be used for reporting a warning on a Connection object, Statement object & ResultSet object?
Answers:
  1. getWarnings()
  2. getWarned()
  3. getWarning()
  4. getError()
  5. getErrors()
39. Which of the following are valid ways to define a thread in Java?
Answers:
  1. Create a subclass of java.lang.Thread class
  2. Create a class that implements java.lang.Runnable
  3. Define method run() in a class
  4. Define method call() in a class
40. JDBC is based on:
Answers:
  1. X/Open CLI (Call Level Interface)
  2. JDBC/Open CLI
  3. Java/Open CLI
  4. V/OPEN CLI
  5. V/CLOSE CLI
41. Which of the following statements regarding abstract classes are true?
Answers:
  1. All methods declared in an abstract class must be abstract.
  2. Any subclass (abstract or concrete class) of an abstract class must implement all the methods declared in the parent abstract class.
  3. Any concrete class must implement all the methods of the parent abstract class which are not implemented in the super hierarchy tree.
  4. The abstract class may have method implementation.
42. Which of the following is the name of the cookie used by Servlet Containers to maintain session information?
Answers:
  1. SESSIONID
  2. SERVLETID
  3. JSESSIONID
  4. CONTAINERID
43. Which method is called by the servlet container just after the servlet is removed from service?
Answers:
  1. public void finalize() {// code…}
  2. public void destroy() {// code…}
  3. public void destroy()throws ServletException {// code…}
  4. public void finalize()throws ServletException {// code…}
44. Which method in the HttpServlet class corresponds to the HTTPPUT method?
Answers:
  1. put
  2. doPut
  3. httpPut
  4. putHttp
45. Which of the following illustrates correct synchronization syntax?
Answers:
  1. public synchronized void Process(void){}
  2. public void Process(){ synchronized(this){ } }
  3. public void synchronized Process(){}
  4. public synchronized void Process(){}
46. The transaction attribute of a bean is set to ‘TX_REQUIRES_NEW.’ What can be inferred about its behavior?
Answers:
  1. It initiates a new transaction only when the previous one is concluded.
  2. It initiates a new transaction without waiting for the previous one to conclude.
  3. It sends the request to the EJB container for initiating a new bean.
  4. The bean manages its own transaction.
47. How many objects are created in the given code?
Object x, y, z;
x = new Object();
y = new Object();
Answers:
  1. 0
  2. 1
  3. 2
  4. 3
48. How does the set collection deal with duplicate elements?
Answers:
  1. Duplicate values will cause an error at compile time.
  2. A set may contain elements that return duplicate values from a call to the equals method.
  3. An exception is thrown if you attempt to add an element with a duplicate value.
  4. The add method returns false if you attempt to add an element with a duplicate value.
49. What is the output of the given program?
public class Test106 {
public static void main(String[] args) {
Integer x = 0;
Integer y = 0;
Integer a = 1000;
Integer b = 1000;
System.out.println( (a==b) + “; ” + (x==y) );
}
}
Answers:
  1. The code will not compile, because Integer is a class, and an object must be created by calling its constructor: Integer a = new Integer(1); or, alternatively, a primitive type must be used: int a = 1;
  2. true; true
  3. false; false
  4. false; true
50. 1 <libraryPrefix:handlerName parameterNAme=”value”>
2 <%=23*counter %>
3 <b>Congratulations!</b>
Which of the following is the correct way to complete the code snippet above?
Answers:
  1. </libraryPrefix:handlerName>
  2. </libraryPrefix:handlerName paremeterName=”value”>
  3. </handlerName>
  4. <libraryPrefix>
51. Which of the following transaction modes are supported by Enterprise Java Beans?
Answers:
  1. TX_NOT_SUPPORTED
  2. TX_BEAN_MANAGED
  3. TX_REQUIRED
  4. TX_MANDATORY
  5. All of the above
52. What is the output of the given program?
public class Test120 extends _Test120 {
{
System.out.print(“_INIT”);
}
static {
System.out.print(“_STATIC”);
}
Test120() {
System.out.print(“_CONST”);
}
public static void main(String[] args) {
System.out.print(“_MAIN”);
new Test120();
}
}
class _Test120 {
{
System.out.print(“_BIN”);
}
static {
System.out.print(“_START”);
}
_Test120() {
System.out.print(“_BASE”);
}
}
Answers:
  1. _START_STATIC_MAIN_BIN_BASE_INIT_CONST
  2. _STATIC_START_MAIN_BIN_BASE_INIT_CONST
  3. _STATIC_MAIN_START_BIN_BASE_INIT_CONST
  4. _START_MAIN_STATIC_BIN_BASE_INIT_CONST
53. Which distributed object technology is most appropriate for systems that consist entirely of Java objects?
Answers:
  1. RMI
  2. CORBA
  3. DCOM
  4. COM
  5. JDBC
54. The following code was written to save a handle to an EJBObject named ‘bookEJBObject’ for an online book shop:
javax.ejb.Handle bookHandle = _____________;
ObjectOutputStream stream = new ObjectOutputStream(newFileOutputStream(fileName));
stream.writeObject(bookHandle);
stream.close();
Which of the following methods should be filled in the blank?
Answers:
  1. (Handle) bookEJBObject()
  2. bookEJBObject.getHandle()
  3. bookEJBObject.getEJBHandle()
  4. newHandleInstance()
55. Which sequence will be printed when the following program is run?
import java.util.*;
public class Test {
public static void main(String str[]) {
List l = new ArrayList();
l.add(”1”);
l.add(”2”);
l.add(1,”3”);
System.out.println(l);
}
}
Answers:
  1. [1, 3, 2]
  2. [1, 3, 1]
  3. [1, 1, 3]
  4. [1, 1, 2]
  5. This code will generate an error.
56. Conventionally, which directory do servlet class files get placed on?
Answers:
  1. WEB-INFservlets
  2. webappservlets
  3. WEB-INFclasses
  4. WEB-INF
57. Which is a proper way to declare and throw exception of class XYException?
Answers:
  1. class XYException extends Exception {} … throw new XYException();
  2. class XYException implements Exception {} … throw new XYException();
  3. class XYException extends Exception {} … throw new Exception(“”XYException””);
  4. class XYException implements Exception {} … throw new Exception(“”XYException){};
58. Which of the following JDBC methods is used to retrieve large binary objects?
Answers:
  1. getBinaryStream()
  2. getText()
  3. getAsciiStream
  4. getString()
  5. getUniStream()
59. What is the output of the given program?
public class Test129 {
public static void main(String[] args) {
A a = new A2();
B b = new B2();
System.out.println(a.a + “” + b.b);
}
}
class A { int a = 1; }
class A2 extends A { int a = 2; }
class B { public int b = 1; }
class B2 extends B { public int b = 2; }
Answers:
  1. 1
  2. 2
  3. 11
  4. 22
60. What exception is thrown by this code, if arr[j]>arr[j+1]:
public static void main(String[] args) {
int []arr={12,23,43,34,3,6,7,1,9,6};
int temp;
for (int i=0;i<arr.length;i++)
for (int j=0;j<arr.length-i;j++ )
{
if (arr[j]>arr[j+1])
temp=arr[j];
arr[j+1]=arr[j];
arr[j+1]=temp;
}
}
}
for(int i=0; i<arr.length; i++)
{
System.out.print(arr[i] + ” “);
}
}
Answers:
  1. NumberFormatException
  2. ArrayIndexOutOfBoundException
  3. IOException
61. Which of the following is a well-known HTTP port?
Answers:
  1. 21
  2. 25
  3. 8080
  4. 80
  5. 137
62. What is the output of the given console application?
public class Test31 {
public static void main(String[] args) {
test();
}
public static void test() {
try {
System.out.print(“-try”);
return;
} catch (Exception e) {
System.out.print(“-catch”);
} finally {
System.out.print(“-finally”);
}
}
}
Answers:
  1. -try
  2. -try-catch
  3. -try-finally
  4. -try-catch-finally
63. Which of these interfaces are used by implementations of models for JTable?
Answers:
  1. TableModel
  2. TableColumnModel
  3. TableSelectionModel
  4. ListModel
64. Which of the following require explicit try/catch exception handling by the programmer?
Answers:
  1. Accessing a method in another class
  2. Attempting to open a network socket
  3. Attempting to open a file
  4. Traversing each member of an array
65. What is the output of the given program?
public class Test89 {
public static void main(String[] args) {
T x = new T(“”X””, null); x.start();
T y = new T(“”Y””, x); y.start();
T z = new T(“”Z””, y); z.start();
}
}
class T extends Thread {
private Thread predecessor;
private String name;
public T(String name, Thread predecessor) { 
this.predecessor = predecessor; 
this.name = name; 
}
public void run() {
try {
Thread.sleep((int)(Math.random()*89));
System.out.print(name);
} catch (InterruptedException ie) {
ie.printStackTrace();
}
}
}
Answers:
  1. Always XYZ
  2. Always ZYX
  3. Any of the following: XYZ, XZY, YXZ, YZX, ZXY, ZYX
  4. Any of the following: XYZ, ZYX
66. Which of the following code snippets will take transform input string “2012/06/05” to output string “05 – 06 – 2012”?
Answers:
  1. String dateString = “2012/06/05”; Date date = new SimpleDateFormat(“yyyy/MM/dd”).parse(dateString); SimpleDateFormat sdf = new SimpleDateFormat(“dd – MM – yyyy”); System.out.println(sdf.format(date));
  2. String dateString = “2012/06/05”; Date date = new SimpleDateFormat(“yyyy/MM/dd”).format(dateString); SimpleDateFormat sdf = new SimpleDateFormat(“dd – MM – yyyy”); System.out.println(sdf.parse(date));
  3. String dateString = “2012/06/05”; Date date = new SimpleDateFormat(“dd – MM – yyyy”).format(dateString); SimpleDateFormat sdf = new SimpleDateFormat(“yyyy/MM/dd”); System.out.println(sdf.parse(date));
  4. String dateString = “2012/06/05”; Date date = new SimpleDateFormat(“dd – MM – yyyy”).parse(dateString); SimpleDateFormat sdf = new SimpleDateFormat(“yyyy/MM/dd”); System.out.println(sdf.format(date));
67. Which statement is true regarding ServletContext Initialization Parameters in the deployment descriptor?
Answers:
  1. They are accessible by all servlets in a given web application.
  2. They are accessible by all servlets in a given session.
  3. They are accessible by all servlets in a given HTTP request.
  4. They are accessible by all servlets in a given container.
68. Which of the following statements is true of the HashMap class?
Answers:
  1. It stores information as key/value pairs.
  2. Elements are returned in the order they were added.
  3. It does not permit null keys.
  4. It does not permit null values.
69. Which distributed object technology is most appropriate for systems that consist of objects written in different languages and that execute on different operating system platforms?
Answers:
  1. RMI
  2. CORBA/li>
  3. COBRA
  4. DCOM
  5. COM
70. What is the output of the given code?
public class Test15 {
public static void main(String[] args) {
VO a = new VO(2);
VO b = new VO(3);
swapONE(a, b);
print(a, b);
swapTWO(a, b);
print(a, b);
}
private static void print(VO a, VO b) {
System.out.print(a.toString() + b.toString());
}
public static void swapONE(VO a, VO b) {
VO tmp = a;
a = b;
b = tmp;
}
public static void swapTWO(VO a, VO b) {
int tmp = a.x;
a.x = b.x;
b.x = tmp;
}
}
class VO {
public int x;
public VO(int x) {
this.x = x;
}
public String toString() {
return String.valueOf(x);
}
Answers:
  1. 2332
  2. 3232
  3. 3223
  4. 2323
71. What would happen on trying to compile and run the following code?
class House {
public final void MaintainMethod() {
System.out.println(“MaintainMethod”);
}
}
public class Building extends House {
public static void main(String argv[]) {
House h = new House();
h.MaintainMethod();
}
}
Answers:
  1. A runtime error will occur because class House is not defined as final.
  2. Successful compilation and output of “MaintainMethod” at run time.
  3. A compilation error indicating that a class with any final methods must be declared final itself.
  4. A compilation error indicating that you cannot inherit from a class with final methods.
72. Which of the following code snippets will generate five random numbers between 0 and 200?
Answers:
  1. Random r = new Random(); for (int i = 0; i < 5; i++) { System.out.println(r.nextInt(0,200)); }
  2. Random r = new Random(200); for (int i = 0; i < 5; i++) { System.out.println(r.nextInt()); }
  3. Random r = new Random(); for (int i = 0; i < 5; i++) { System.out.println(r.nextInt(200)); }
  4. Random r = new Random(200); for (int i = 0; i < 5; i++) { System.out.println(r.nextInt(0)); }
73. What will be the output when this code is compiled and run?
public class Test {
public Test() {
Bar b = new Bar();
Bar b1 = new Bar();
update(b);
update(b1);
b1 = b;
update(b);
update(b1);
}
private void update(Bar bar) {
bar.x = 20;
System.out.println(bar.x);
}
public static void main(String args[]) {
new Test();
}
private class Bar {
int x = 10;
}
}
Answers:
  1. The code will fail to compile.
  2. 10 10 10 10
  3. 20 20 20 20
  4. 10 20 10 20
74. Which class contains a method to create a directory?
Answers:
  1. File
  2. DataOutput
  3. Directory
  4. FileDescriptor
  5. FileOutputStream
75. What is the output of the given program?
public class Test130 {
public static void main(String[] args) {
A a = new A2();
B b = new B2();
System.out.println(a.a + “””” + b.b());
}
}
class A {
public int a = 1;
}
class A2 extends A { 
public int a = 2;
}
class B { 
public int b() { return 1; }
}
class B2 extends B { 
public int b() { return 2; }
}
Answers:
  1. 11
  2. 12
  3. 21
  4. 22
76. Which of the following is the correct syntax for suggesting that the JVM perform garbage collection?
Answers:
  1. System.setGarbageCollection();
  2. System.out.gc();
  3. System.gc();
  4. System.free();
77. Why can’t a Graphics object be created using the following statement?
Graphics g = new Graphics();
Answers:
  1. The Graphics class is a final class.
  2. The Graphics class is an abstract class.
  3. The constructor of the Graphic class needs a color object to be passed as a parameter, e.g Graphics g = new Graphics(new Color());.
78. Select all correct statements:
Answers:
  1. Vector is synchronized, ArrayList is not synchronized
  2. Hashtable is synchronized, HashMap is not synchronized
  3. Vector is not synchronized, ArrayList is synchronized
  4. Hashtable is not synchronized, HashMap is synchronized
79. What is the output of the given program?
public class Test97 {
public static void main(String[] args) {
int[][] a = new int[2][2];
System.out.println(a.length);
}
}
Answers:
  1. 0
  2. 2
  3. 3
  4. 4
80. Which of the following is false?
Answers:
  1. A scrollable ResultSet can be created in JDBC 2.0 API.
  2. The cursor is moved forward using next().
  3. The cursor is moved backward using previous().
  4. A while loop can be used because next() & previous() methods return false beyond the resultset.
  5. A while loop can be used because next () & previous () methods return -1 beyond the resultset.
81. Consider the following code:
public class Jam {
public void apple(int i, String s) {
}
//ABC
}
Choose possible valid code replacements of “//ABC” among the choices:
Answers:
  1. public void apple(String s, int i) {}
  2. public int apple(int i, String s) {}
  3. public void apple(int i, String mystring) {}
  4. public void Apple(int i, String s) {}
82. RMI allows remote communication between:
Answers:
  1. C++ and Java
  2. C and Java
  3. Pascal and Java
  4. Java and Java
  5. Java and TCP/IP
83. Which of the following interfaces makes it possible for Java to save an object to a file and turn it into a data stream?
Answers:
  1. java.io.Serialization
  2. java.net.Serializable
  3. java.net.Serialization
  4. java.io.Serializable
  5. java.net.io.Serializable
84. How many objects are created in the given code?
Object x, y, z;
x = new Object();
y = new Object()
Answers:
  1. 0
  2. 1
  3. 2
  4. 3
85. As part of the type erasure process, when compiling a class or interface that extends a parameterized class or implements a parameterized interface, the compiler may need to create a synthetic method, called a _________.
Answers:
  1. bridge method
  2. helper method
  3. stub method
  4. raw method
86. Consider the following code:
public static void main(String bicycle[])
{
System.out.println(bicycle[0]);
}
What would be the result if “java TwoTyre one two” is entered in the command line?
Answers:
  1. one
  2. two
  3. TwoTyre
  4. None of the above
87. With regard to the destroy lifecycle method, identify the correct statements about its purpose or about how and when it is invoked.
Answers:
  1. It gives the servlet an opportunity to clean up resources.
  2. Like try-catch, it is called upon an exception.
  3. It is rarely used but can be called to remove a servlet from memory.
  4. It isn’t called if the server crashes.
88. What is the term to describe a situation where two or more threads are blocked forever, waiting for each other?
Answers:
  1. deadlock
  2. starvation
  3. livelock
  4. liveness
89. What will be the output of the following code?
public class MyTest {
public static void main(String[] args) {
for (int i=0; i > 10; i+=2) {
System.out.println(i);
}
}
}
Answers:
  1. Nothing will be printed.
  2. It will print the following output: 0 2 4 6 8
  3. Compile time error
  4. It will print the following output: 0 1 2 3 4 5 6 7 8 9
90. Which of the following cannot apply to constructors?
Answers:
  1. Name same as class name
  2. Void return type
  3. Can have parameters
  4. Overloading

Finally no more words require about the JAVA TEST V3 information in this session of this content. If you are require knowing more, Please ask to us via our contact us form or comment box. Please make sure that, you don’t send Personal information via the Comment box. Thanks for Being with us.

No comments:

Post a Comment