www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor Kérdések száma: 30 kérdés Kitöltési idő: 1:11:48 Pont egység: +6 -2 Értékelés: Alapértelmezett értékelés Típus: Mindig van legalább egy jó válasz (N/1..N) Source: http://scjptest.com
Serialization 2:42
1. Given the code. What is the result? [source:java] import java.io.*; public class Hotel implements Serializable { private Room room = new Room(); public static void main(String[] args) { Hotel h = new Hotel(); try { FileOutputStream fos = new FileOutputStream("Hotel.dat"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(h); oos.close(); } catch(Exception ex) { ex.printStackTrace(); } } } class Room { } [source] a b c d
An exception is thrown at runtime. An instance of Hotel is serialized. Compilation fails. An instance of Hotel and an instance of Room are both serialized. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 1/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Core 1:07
2. Given the code. What is the result? [source:java] public static void main(String args[]) { String str = "null"; if (str == null) { System.out.print("1"); } else if (str.length() == 0) { System.out.print("2"); } else { System.out.print("3"); } } [source] a b c d e
"1" is printed. Compilation fails. "2" is printed. An exception is thrown at runtime. "3" is printed. Csak tipp +3 1-
3.
a
b
c
d
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Given: d is a valid, non-null java.util.Date object df is a valid, non-null java.text.DateFormat object set to the current locale. What outputs the current locale's country name and the appropriate version of date?
Biztosan jó + 12 4 Calendar 2:39
[source:java] Locale l = Locale.getDefault(); System.out.println(l.getDisplayCountry() + " " + df.setDateFormat(d)); [source] [source:java] Locale l = Locale.getLocale(); System.out.println(l.getDisplayCountry()); [source] [source:java] Locale l = Locale.getDefault(); System.out.println(l.getDisplayCountry() + " " + df.format(d)); [source] [source:java] Locale l = Locale.getLocale(); System.out.println(l.getDisplayCountry() + " " + df.setDateFormat(d)); [source] Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 2/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Core 2:57
4. What do you need to do to correct compilation errors? (Select two) [source:java] public class Creature { private int legCount; private int wingCount; public Creature(int legCount) { this.legCount = this.legCount; this.wingCount = 0; } public String toString() { return "legs=" + this.legCount + " wings=" + wingCount; } } public class Animal extends Creature { public Animal(int legCount) { this.wingCount = 0; } } [source] a b c d e f
change the wingCount variable in the class Creature to protected. insert a call to super(legCount) into Animal constructor. change the string "this.wingCount = 0" in the class Animal to "super.wingCount = 0" insert a call to super() into Creature constructor. insert a call to super() into Animal constructor. insert a call to this() into Animal constructor. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 3/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Collection 2:38
5.
Given the code. What is the result? [source:java] import java.util.Collections; import java.util.LinkedList; public class TryMe { public static void main(String args[]) { LinkedList list = new LinkedList(); list.add("BbB1"); list.add("bBb2"); list.add("bbB3"); list.add("BBb4"); Collections.sort(list); for (String str : list) { System.out.print(str + ":"); } } } [source]
a b c d e f
"BBb4:BbB1:bBb2:bbB3:" is printed. "BBb4:bbB3:bBb2:BbB1:" is printed. "bbB3:bBb2:BbB1:BBb4:" is printed An exception is thrown at runtime. Compilation fails. "BbB1:bBb2:bbB3:BBb4:" is printed. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 4/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Exception 2:16
6. Given the code. What is the result? [source:java] public static void main(String args[]) { try { String arr[] = new String[10]; arr = null; arr[0] = "one"; System.out.print(arr[0]); } catch(Exception ex) { System.out.print("exception"); } catch(NullPointerException nex) { System.out.print("null pointer exception"); } } [source] a b c d
"exception" is printed. Compilation fails. "null pointer exception" is printed. "one" is printed. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Biztosan jó + 12 4 Thread 2:09
7. Given the code. What is the result? [source:java] public class Hotel { private static void book() { System.out.print("book"); } public static void main(String[] args) { Thread.sleep(1); book(); } } [source] a b c d
An exception is thrown at runtime. "book" is printed. The code executes normally, but nothing is printed. Compilation fails. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 5/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
GC 2:09
8.
Given the code. Which line of code marks the earliest point that an object referenced by myInt becomes a candidate for garbage collection? [source:java] public void doStuff() { Integer arr[] = new Integer[5]; for (int i = 0; i < arr.length; i++) { Integer myInt = new Integer(i); arr[i] = myInt; } System.out.println("end"); } [source]
a b c d
Line 6 Line 7 Line 5 Line 4 Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Biztosan jó + 12 4 Thread 2:11
9. Give a piece of code. What is true? [source:java] public void waitForSomething() { SomeClass o = new SomeClass(); synchronized (o) { o.wait(); o.notify(); } } [source] a b c d
This code may throw an InterruptedException Reversing the ofrer of o.wait() and o.notify() will cause this method to complete normally. This code may throw an IllegalStateException This code may throw a TimeOutException Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 6/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Generic 2:23
10.
Given the code. What is the result? [source:java] public class TrickyNum { private X x; public TrickyNum(X x) { this.x = x; } private double getDouble() { return x.doubleValue(); } public static void main(String args[]) { TrickyNum a = new TrickyNum(new Integer(1)); System.out.print(a.getDouble()); } } [source]
a b c d
Compilation fails. "1" is printed. An exception is thrown at runtime. "1.0" is printed. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 7/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Core 2:42
11. Given the code. What is the result? [source:java] class Vehicle { public void printSound() { System.out.print("vehicle"); } } class Car extends Vehicle { public void printSound() { System.out.print("car"); } } class Bike extends Vehicle { public void printSound() { System.out.print("bike"); } } public class Test { public static void main(String[] args) { Vehicle v = new Car(); Bike b = (Bike) v; v.printSound(); b.printSound(); } } [source] a b c d e f
"vehiclebike" is printed. Compilation fails. An exception is thrown at runtime. "vehiclecar" is printed. "carcar" is printed. "bikebike" is printed Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 8/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Parameter 2:02
12. Given the code. What is the output? [source:java] public class Test { int a = 10; public void doStuff(int a) { a += 1; System.out.println(++a); } public static void main(String args[]) { Test t = new Test(); t.doStuff(3); } } [source] a b c d
5 4 11 12 Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Biztosan jó + 12 4 String 1:53
13. Given the code. What is the result? [source:java] String test = "This is a test string"; String[] tokens = test.split("\\s"); System.out.println(tokens.length); [source] a b c d e
5 An exception is thrown at runtime Compilation fails 21 0 Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 9/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor 14. a b c d e f
Which three will compile without exception? (Choose three) void book() { synchronized () {} } public void book() { synchronized(Cruiser.class) {} } public synchronized(this) void book() {} public void book() {synchronized(a){}} public synchronized void book() {} private synchronized SomeClass a; Csak tipp +3 1-
15. a b c d e f
a b c d e f g h
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Biztosan jó + 12 4 -
Someone is writing a class MyKey, that will be used as a key in the java.util.HashMap. Which methods should be overriden to guarantee that MyKey works as HashMap key? (Select all that apply)
Hash 2:04
public int hashCode() public int has() public int compareTo(Object) public boolean equals(Object) public int compareTo(MyKey) public boolean equals(MyKey) Csak tipp +3 1-
16.
Thread 1:59
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Biztosan jó + 12 4 -
A Java bean component has the following field: private boolean done; Which method declarations follow the JavaBean standards for getting/settings this field? (Choose 3)
Java bean 2:10
public boolean isDone() public void setDone(boolean done) public void setDone() public void isDone() public boolean getDone() public boolean getDone(boolean done) private boolean setDone(boolean done) public boolean setDone(boolean done) Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 10/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Serialization 2:43
17. Given the code. What is the result? [source:java] import java.io.*; public class Hotel implements Serializable { private transient Room room = new Room(); public static void main(String[] args) { Hotel h = new Hotel(); try { FileOutputStream fos = new FileOutputStream("Hotel.dat"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(h); oos.close(); } catch(Exception ex) { ex.printStackTrace(); } } } class Room { } [source] a b c d
An exception is thrown at runtime. Compilation fails. An instance of Hotel and an instance of Room are both serialized. An instance of Hotel is serialized. Csak tipp +3 1-
18. a b c d
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
What is true about has-a and is-a relationships? (Choose two)
Biztosan jó + 12 4 Theory 1:57
Inheritance represents a has-a relationship. Inheritance represents an is-a relationship. Instance variables can be used when creating a has-a relationship. Instances must be used when creating a has-a relationship. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 11/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Thread 2:59
19.
Give a piece of code. Which two are possible results? (Select two) [source:java] public class Cruiser { private int a = 0; public void foo() { Runnable r = new LittleCruiser(); new Thread(r).start(); new Thread(r).start(); } public static void main(String arg[]) { Cruiser c = new Cruiser(); c.foo(); } public class LittleCruiser implements Runnable { public void run() { int current = 0; for (int i = 0; i < 4; i++) { current = a; System.out.print(current + ", "); a = current + 2; } } } } [source]
a b c d e
0, 2, 4, 6, 8, 10, 2, 4, 0, 2, 4, 0, 2, 4, 6, 6, 0, 2, 4, 6, 8, 10, 12, 14, 0, 2, 4, 6, 8, 10, 12, 14, 0, 0, 2, 2, 4, 4, 6, 6, 8, 8, 10, 10, 12, 12, 14, 14, 0, 2, 4, 6, 8, 10, 12, 14, Csak tipp +3 1-
20.
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Given: [source:java] System.out.printf("Pi = %f and E = %b", Math.PI, Math.E); [source] What is the output?
Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Biztosan jó + 12 4 Core 1:46
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 12/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor 21.
Which three statements concerning the use of the java.io.Serializable interface are true? (Choose three)
a b c d e
The values in fields with the volatile modifier will not survive serialization and deserialization. An object serialized on one JVM can be deserialized on a different JVM. object from classes tha use aggregation cannot be serialized. The values in field with the transient modifier will not survive serialization and deserialization. It is legal to serialize an object of a type that has a supertype that does not implement java.io.Serializable Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Serialization 2:24
Biztosan jó + 12 4 Calendar 2:12
22. Given the code. What is the result? [source:java] DateFormat df = DateFormat.getDateInstance(); df.setLocale(Locale.US); Calendar c = Calendar.getInstance(); c.set(Calendar.YEAR, 2009); c.set(Calendar.MONTH, 5); c.set(Calendar.DAY_OF_MONTH, 1); String formattedDate = df.format(c.getTime()); System.out.println(formattedDate); [source] a b c d
June 1, 2009 Compilation fails July 1, 2009 An exception is thrown at runtime Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 13/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Collection 2:55
23.
Given the code. What is the result? [source:java] import java.util.Collections; import java.util.LinkedList; import java.util.List; public class HashTest { private String str; public HashTest(String str) { this.str = str; } @Override public String toString() { return this.str; } public static void main(String args[]) { HashTest h1 = new HashTest("2"); String s1 = new String("1"); List list = new LinkedList(); list.add(h1); list.add(s1); Collections.sort(list); for (Object o : list) { System.out.print(o + " "); } } } [source]
a b c d
"2 1" is printed. "1 2" is printed. Compilation fails. An exception is thrown at runtime. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 14/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor 24. a b c d e f g
A developer is creating a class A, that needs to access a class B. The B class is deployed in a jar named superLib.jar. Which three, will allow the developer to use the B class while compiling the A class. (choose three)
The jar file is located at /myfolder/superLib.jar and the A class is compiled using "javac -d /myfolder/superLib.jar A.java" The jar file is located at $JAVA_HOME/jre/lib/ext/superLib.jar The jar file is located at /myfolder/superLib.jar and the A class is compiled using "javac -classpath /myfolder/superLib.jar A.java" The jar file is locate at /myfolder/superLib.jar and a classpath environment variable is set that includes /myfolder/superLib.jar The jar file is located at $JAVA_HOME/jre/classes/superLib.jar The jar file is located at /myfolder/superLib.jar and the A class is compiled using "javac -cp /myfolder/superLib.jar/B A.java" The jar file is located at /myfolder/superLib.jar and a classpath environment variable is set that includes /myfolder/superLib.jar/B.class Csak tipp +3 1-
25. a b c d e f
Theory 3:09
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
What is true? (Choose three)
Biztosan jó + 12 4 Theory 2:25
A public static method in class Z can be called by a subclass of Z without explicitly referencing the class Z. A final method in class Z can be abstract if and only if Z is abstract. A protected method in class Z can be overriden by any subclass of Z. A private static method can be called only within other static methods in class Z. A non-static public final method in class Z can be overriden in any subclass of Z. A method with the same signature as a private final method in class Z can be implemented in a subclass of Z. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 15/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Collection 2:45
26. Given the code. What is the result? [source:java] import java.util.Arrays; public class HashTest { private String str; public HashTest(String str) { this.str = str; } @Override public String toString() { return this.str; } public static void main(String args[]) { HashTest h1 = new HashTest("2"); String s1 = new String("1"); Object arr[] = new Object[2]; arr[0] = h1; arr[1] = s1; Arrays.sort(arr); for (Object o : arr) { System.out.print(o + " "); } } } [source] a b c d
Compilation fails. "2 1" is printed. An exception is thrown at runtime. "1 2" is printed. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 16/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Core 2:16
27. Given the code. What is the result? [source:java] int i = 10; while (i++
a b c d e
13 10 Line 5 will be never reached. 12 11 Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
Biztosan jó + 12 4 Override 2:50
28. Given the code. What is the result? [source:java] class Hotel { public void book() throws Exception { throw new Exception(); } } public class SuperHotel extends Hotel { public void book() { System.out.print("booked"); } public static void main(String args[]) { Hotel h = new SuperHotel(); h.book(); } } [source] a b c d
The code runs without any output. Compilation fails. "booked" is printed. An exception is thrown at runtime. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 17/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Serialization 2:44
29. Given the code. What is the result? [source:java] import java.io.*; public class Hotel implements Serializable { private Room room = new Room(); public static void main(String[] args) { Hotel h = new Hotel(); try { FileOutputStream fos = new FileOutputStream("Hotel.dat"); ObjectOutputStream oos = new ObjectOutputStream(fos); oos.writeObject(h); oos.close(); } catch(Exception ex) { ex.printStackTrace(); } } } class Room implements Serializable { } [source] a b c d
An instance of Hotel is serialized. Compilation fails. An exception is thrown at runtime. An instance of Hotel and an instance of Room are both serialized. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 18/19 Minta feladatsor
Biztosan jó + 12 4 -
www.testline.hu v4.0.9 (2017.01.02.) 2017.01.10. 19:39:15 vendég
TestLine - SCJP sample 2 Minta feladatsor
Vehicle 2:42
30. Given the code. What is the result? [source:java] class Vehicle { public void printSound() { System.out.print("vehicle"); } } class Car extends Vehicle { public void printSound() { System.out.print("car"); } } class Bike extends Vehicle { public void printSound() { System.out.print("bike"); } } public class Test { public static void main(String[] args) { Vehicle v = new Car(); Car c = (Car) v; v.printSound(); c.printSound(); } } [source] a b c d e f
"bikebike" is printed An exception is thrown at runtime. "vehiclebike" is printed. "vehiclecar" is printed. Compilation fails. "carcar" is printed. Csak tipp +3 1-
Talán jó + 4.5 1.5 -
Nem válaszolok +6 2-
Valószínűleg jó +9 3-
TestLine - SCJP sample 2 oldal 19/19 Minta feladatsor Powered by TCPDF (www.tcpdf.org)
Biztosan jó + 12 4 -