Search Header Logo

Assessment Java Programming Skills

Authored by Christiancarmine ESPOSITO

Computers

University

Used 17+ times

Assessment Java Programming Skills
AI

AI Actions

Add similar questions

Adjust reading levels

Convert to real-world scenario

Translate activity

More...

    Content View

    Student View

10 questions

Show all answers

1.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code

import java.util.Arrays;

import java.util.Comparator;

public class ComparatorTest {

public static void main(String args[]){

String[] ar= {“c”,”d”,”b”,”a”,”e”};

InnerClass in=new InnerClass();

Arrays.parallelSort(ar, in);

for(String str : ar)

System.out.println(str +””);

System.out.println(Arrays.binarySearch(ar, “b”));

}

static class InnerClass implements Comparator<String>{

public int compare(String s1, String s2){

return s2.compareTo(s1);

}

}

}

e d c b a -1

a b c 0 e d

d b c e a 1

e b a d c

2.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code

import java.util.LinkedHashSet;

import java.util.Set;

public class LinkedHashSetTest {

public static void main (String args[]){

Set s=new LinkedHashSet();

s.add(“1”);s.add(1);

s.add(3);

s.add(2);

System.out.println(s);

}

}

[1, 1, 2, 3]

[1, 2, 2 3[

[1, 1, 3, 2]

[1, 2, 3]

3.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What will be the output of the following code

import java.util.ArrayList;

import java.util.List;

public class ListDemo {

public static void main (String args[]) {

List<Integer> list=new ArrayList<Integer>();

list.add(2); list.add(3); m(list);

public static void m(List<Number> list) {

System.out.println(list);

}

}

}

3

3.0

Compile time exception

Runtime exception

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of those doesn’t have an index based structure?

List

Set

Map

Vector

5.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

java.util.Collections is a:

Class

Interface

Object

None of the above

6.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

In Iterator, hasMoreElements() method of Enumeration has been changed to:

hasNextElement()

isNext()

hasNext()

name remains same

7.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

What of the following is the default value of a local variable?

null

0

Depends upon the type of variable

Not assigned

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Microsoft

Continue with Microsoft

or continue with

Facebook

Facebook

Apple

Apple

Others

Others

Already have an account?