JAVA Quiz

/5

Misc

1 / 5

What will be the output of below code:

class variable_scope

{

public static void main(String args[])

{

int x;

x = 5;

{

int y = 6;

System.out.print(x + " " + y);

}

System.out.println(x + " " + y);

}

}

2 / 5

What will be the output of below code:

class String_demo

{

public static void main(String args[])

{

char chars[] = {'a', 'b', 'c'};

String s = new String(chars);

System.out.println(s);

}

}

3 / 5

What will be the output of below code:

class output

{

public static void main(String args[])

{

String c = "Hello i love java";

boolean var;

var = c.startsWith("hello");

System.out.println(var);

}

}

4 / 5

What is the valid function to find the length of the string?

5 / 5

What will be the output of below code:

class Output

{

public static void main(String args[])

{

int arr[] = {1, 2, 3, 4, 5};

for ( int i = 0; i < arr.length - 2; ++i)

System.out.println(arr[i] + " ");

}

}

Your score is

The average score is 46%

0%

Exit