oDesk Java Programme test Answer 2014 | oDesk Skill Test Answer


oDesk Java Programme test Answer 2014

 Question no.1: what is the java net . IDN class in 1.6?


Ans: methods the convert internationalized domain names(IDNs)  between a normal Unicode representation and an ASCII compatible encoding (ACE) representation .

  Question no.2: which of these interfaces are used by implementations of model for JTable?

Ans: Table Model, Table CommomModel

Question no.3: how many times can classes be nested within a class?

Ans: any number of times.

Question no.4: one method in your application needs to be synchronized.which of the following options are correct for synchronization?

Ans: a.public void Process(){synchronized(this){}}
b.public void synchronized Process(){}

Question no.5: what could be the replacement of "//ABC" in the following code 
public class jam
{
public void apple(int i, String s)
{}
//ABC
}

Ans.: a. public void apple (string s , int i ){}
b. public void apple(int i , string s){}

Question no.6: what will be the output when the following code is complied and run?
public class test 
{
public static void main( string args[])
{
int i;
i= 3;
system.out.print((int)i*2.5/3.0);
}
}

Ans: the code will print 2.5

Question no.7: what would happen on trying to compile and run the following code?
public  class MainCls
{
public Static Void Main(String args [])
{
system.out .printIn("My Text")
}
}

Ans: the code will compile. a runtime error will occur because "main" is not properly defined.

Question no.8: which of the following are "keywords" in Java?

Ans: a.default
b. throws

Question no.9: which of the following statements is true of the HashMap class?

Ans: a.it stores information as key/ value pairs.

Question no.10: how does the set collection deal with duplicate elements?

Ans: the add method returns false if you attempt to add an element with a  duplicate value.

Question no.11: what is wrong with the following code?
class X extends Exception{}
public class Y
{
public void foo()
{
try{
b();
}
finally{
ba();
}
catch(MyException e) {]
}
public void ba()throws X {
throw new X ();
}
public void ba()  throws  RunTime Exception  {
throw new RunTime  Exception();
}
}

Ans: none of the above

Question no.12: is the following code valid?
InetAddress ad =  InetAddress.getByName("195.186.2.111");

Ans: yes

 Question no.13: which of the following can't apply to constructors?

Ans: void return type

Question no.14: choose the correct declarations for the main() method which will allow the class to be run as a standalone program.

Ans: public static void main (String str[])

Question no.15: for a class defined inside a method , what  rule governs access to the variable of the enclosing method?

Ans: the class can only access transient variables.  

Question no.16: a method can be defined as native to:

Ans: a.get to access hardware that Java does not know about.
b.write optimized code for performance in language such as C/C++

Question no.17: what will be the output of the following line?
system.out.print(Math floor(-2.1));

Ans: -3.0

   Question no.18: for the given variable , which of the following will compile without an error?
char c ='c';
int j =50;
double d =80;
long l =200;
string s = "Goodbye";

Ans: s+ =i


 

0 comments:

Post a Comment