Test
java
Este test tiene tiempo límite, así que se abre en el reproductor de siempre.
Preguntas del test (30)
1Which of the following are legal lines of Java code?
1. int w = (int)888.8;
2. byte x = (byte)100L;
3. long y = (byte)100;
4. byte z = (byte)100L;- A1 and 2
- B2 and 3
- C3 and 4
- Dall are correct
2what will be the output of the program
public class Test3
{ public static void main(String a[])
{ int x=10;
for(int y=0;y<5;y++,x--)
System.out.print(x+" , ");
}
}- A10,9,8,7,6,
- B9,8,7,6,5,
- CCompilation fails
- DAn exception is thrown at runtime
3Which of these is an incorrect array declaration?
- Aint arr[] = new int[5]
- Bint [] arr = new int[5]
- Cint arr[][] = new int[5]
- Dint arr[] = int [5] new
4class While
{public static void main(String a[])
{ int x=0;
while(1) //line 6
{
System.out.print("x plus one is "+(x+1)); //line 8
}
}
}
Which statement is true?- A(a)There is a syntax error on line 1
- BThere is a syntax error on line 6
- CThere is a syntax error on line 1,6& 8
- DNo Error
5what will be the output of the program?
class Demo
{
public static void main(String a[])
{
int x=0;
float y=10.0;
System.out.println(x+" "+y);
}
}- A0 10.0
- B0 10
- Ccompilation error
- D) run time error
6 Arrays in Java are implemented as?
- Aclass
- Bobject
- Cvariable
- Dnon of the above
7Which of these functions is called to display the output of an applet
- Adisplay()
- Bpaint()
- Cdisplayapplet()
- DpaintApplet()
815.What is the output of this program?
class output
{
public static void main(String args[])
{
String a="hello i love java";
System.out.println(indexof('i')+" "+indexof('o')+" "
+lastIndexof('i')+" "+lastIndexof('o') ));
}
}- A6 4 6 9
- B5 4 5 9
- C7 4 7 9
- D8 4 8 9
9What is the output of this program?
class array_output
{
public static void main(String args[])
{
int array_variable [] = new int[10];
for (int i = 0; i < 10; ++i)
{
array_variable[i] = i;
System.out.print(array_variable[i] + " ");
i++;
}
}
}- A0 1 2 3 4
- B2 3 4 5 6
- C0 2 4 6 8
- D8 7 6 5 4
10Which statement is true about java?
- ASequence dependent programming language
- Bcode dependent programming language
- CPlatform dependent programming language
- DPlatform independent programming language
1117.What is the output of this program?
class string_class
{
public static void main(String args[])
{
String obj = "I LIKE JAVA";
System.out.println(obj.charAt(3));
}
}- Ai
- Bl
- Ck
- De
12. class VarArgs
{
public static void main(String x[])
{
int a[]={1,2,3,4,5};
for(int i:a)
System.out.print(i+" ");
}- A1 3 4 5 2
- B5 4 3 2 1
- C1 2 3 4 5
- D3 4 5 2 1
13Where is array stored in memory?
- Aheap space
- Bstack space
- C) heap space and stack space
- Dfirst generation memory
14What is the output of this program?
class Output
{
public static void main(String args[])
{
Integer i = new Integer(257);
byte x = i.byteValue();
System.out.print(x);
}
}- A0
- B1
- C256
- D257
15Which of these is a protocol for breaking and sending packets to an address across a network?
- ATCIP/IP
- BDNS
- Csocket
- Dproxy server
16What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws UnknownHostException
{
InetAddress obj1 = InetAddress.getByName("cisco.com");
InetAddress obj2 = InetAddress.getByName("sanfoundary.com");
boolean x = obj1.equals(obj2);
System.out.print(x);
}
}- A0
- B1
- Ctrue
- Dfalse
17What is the output of this program?
class Output
{
public static void main(String args[])
{
Object obj = new Object();
System.out.print(obj.getclass());
}
}- AObject
- Bclass Object
- Cclass java.lang.Object
- DCompilation Error
18What is the output of this program?
class A
{
public int i;
protected int j;
}
class B extends A
{
int j;
void display()
{
super.j = 3;
System.out.println(i + " " + j);
}
}
class Output
{
public static void main(String args[])
{
B obj = new B();
obj.i=1;
obj.j=2;
obj.display();
}
}- A1 2
- B2 1
- C1 3
- D3 1
19 Which of these is the interface of legacy?
- Amap
- Benumeration
- Chash map
- Dhash table
20Which of these method returns an instance of DateFormat that can format time information?
- AgetTime()
- Bv getTimeInstance()
- CgetTimeDateinstance()
- DgetDateFormatinstance()
21Which of these formatting strings of SimpleDateFormat class is used to print week of the year?
- Aw
- BW
- Cs
- DS
22What is the output of this program?
import java.net.*;
class networking
{
public static void main(String[] args) throws Exception
{
URL obj = new URL("http://www.sanfoundry.com/javamcq");
URLConnection obj1 = obj.openConnection();
System.out.print(obj1.getContentType());
}
}- Ahtml
- Btext
- Chtml/text
- Dtext/html
23. public class Test
{
public static void main(String a[])
{
for(int i = 0; i < 3; i++)
{
System.out.print(i);
}
System.out.print(i);
}
}- A1 2 3
- B0 1 2 3
- Cerror
- Drun time error
24What is the type of variable ‘b’ and ‘d’ in the below snippet?
int a[], b;
int []c, d;- A) ‘b’ and ‘d’ are int
- B‘b’ and ‘d’ are arrays of type int
- C‘b’ is int variable; ‘d’ is int array
- D) ‘d’ is int variable; ‘b’ is int array
25 Which of these method is used to make a bit zero specified by the index?
- Aput()
- Bset()
- Cremove()
- Dclear()
26What is the output of this program?
import java.util.*;
class Bitset
{
public static void main(String args[])
{
BitSet obj = new BitSet(5);
for (int i = 0; i < 5; ++i)
obj.set(i);
System.out.print(obj.get(3));
}
}- A2
- B3
- C4
- D5
27What is serialization?
- ATurning object in memory into stream of bytes
- BTurning stream of bytes into an object in memory
- CTurning object in memory into stream of bits
- DTurning object in memory into stream bits
28Which of these methods must be made static?
- Amain()
- Bdelete()
- Crun()
- Dfinalise()
29Will this program generate same output when executed again?
class Output
{
public static void main(String args[])
{
int y = double z = Math.random();
System.out.print(y);
}
}- Ayes
- Bno
30What is the output of this program?
import java.util.*;
class hashtable
{
public static void main(String args[])
{
Hashtable obj = new Hashtable();
obj.put("A", new Integer(3));
obj.put("B", new Integer(2));
obj.put("C", new Integer(8));
System.out.print(obj.toString());
}
}- A{C=8, B=2}
- B[C=8, B=2].
- C{A=3, C=8, B=2}
- D[A=3, C=8, B=2].
Información
- Descripción
- Test sobre java, creado por rahul errabelly el 19/01/2018.
- Autor
- rahul errabelly
- Idioma
- English
- Visitas
- 3
- Valoración
- Aún sin valoraciones Valora este test