logo

Crowdly

Browser

Add to Chrome

*Програмування на Jаvа

Looking for *Програмування на Jаvа test answers and solutions? Browse our comprehensive collection of verified answers for *Програмування на Jаvа at dl.nure.ua.

Get instant access to accurate answers and detailed explanations for your course questions. Our community-driven platform helps students succeed!

Which of the following statements about design principles and design patterns are true? (Choose all that apply.)

0%
0%
100%
100%
0%
View this question

What does the following code output?

1: public class Salmon {

2: int count;

3: public void Salmon() {

4: count = 4;

5: }

6: public static void main(String[] args) {

7: Salmon s = new Salmon();

8: System.out.println(s.count);

9: } }

0%
0%
0%
100%
0%
0%
View this question

Which of these statements compile? (Choose all that apply.)

0%
0%
100%
0%
100%
100%
View this question

What is the value of name after an instance of Eagle is serialized and then deserialized?

public class Bird implements Serializable {

protected transient String name = "Bridget";

public void setName(String name) { this.name = name; }

public String getName() { return name; }

public Bird() {

this.name = "Matt";

}

}

public class Eagle extends Bird implements Serializable {

{ this.name = "Janette"; }

public Eagle() {

this.name = "Daniel";

}

}

0%
0%
100%
0%
0%
0%
0%
0%
View this question

What statements are true about the following code? (Choose all that apply.)

public class Tail {}

public class Animal {

public String name;

}

public class Canine extends Animal {

public Tail tail;

}

public class Wolf extends Canine {}

100%
0%
100%
100%
0%
0%
View this question

What is true about the following code? (Choose all that apply)

public class Bear {

 protected void finalize() {

 System.out.println("Roar!");

}

public static void main(String[] args) {

 Bear bear = new Bear();

 bear = null;

 System.gc();

} }

0%
0%
100%
0%
0%
100%
0%
View this question

What is the result of the following class?

1: public class Box<T> {

2: T value;

3:

4: public Box(T value) {

5: this.value = value;

6: }

7: public T getValue() {

8: return value;

9: }

10: public static void main(String[] args) {

11: Box<String> one = new Box<String>("a string");

12: Box<Integer> two = new Box<>(123);

13: System.out.print(one.getValue());

14: System.out.print(two.getValue());

15: } }

0%
0%
0%
100%
0%
0%
View this question

What changes would need to be made to make the following immutable object pattern correct?(Choose all that apply.)

import java.util.List;

public class Duck {

private String name;

private List<Duck> ducklings;

public Duck(String name, List<Duck> ducklings) {

this.name = name;

this.ducklings = new ArrayList<Duck>(ducklings);

}

public String getName() { return name; }

public List<Duck> getDucklings() { return ducklings; }

public String hasDucklings(Predicate<Duck> p) {

return p.test(this) ? "Quack Quack": "";

}

}

0%
0%
0%
100%
0%
0%
0%
View this question

What statements about the following class definition are true? (Choose all that apply.)

public class TicketManager {

private TicketManager() { super(); }

private static TicketManager instance;

public static synchronized TicketManager getInstance() { // k1

if (instance == null) instance = new TicketManager(); // k2

return instance;

}

private int tickets;

public int getTicketCount() { return tickets; }

public void makeTicketsAvailable(int value) { tickets += value; } // k3

public void sellTickets(int value) {

synchronized (this) { // k4

tickets -= value;

}

}

}

0%
0%
100%
0%
0%
100%
View this question

What is the result of the following program?

import java.util.*;

public class MyComparator implements Comparator<String> {

public int compare(String a, String b) {

return b.toLowerCase().compareTo(a.toLowerCase());

}

public static void main(String[] args) {

String[] values = { "123", "Abb", "aab" };

Arrays.sort(values, new MyComparator());

for (String s: values)

System.out.print(s + " ");

}

}

0%
100%
0%
0%
0%
0%
View this question

Want instant access to all verified answers on dl.nure.ua?

Get Unlimited Answers To Exam Questions - Install Crowdly Extension Now!

Browser

Add to Chrome