TestLine - SJP sample átum: 2017.01.10 19:39:22 Kérdések száma: 30 kérdés Kitöltési idő: 1:08:47 Nehézség: Összetett Pont egység: +6-2 Értékelés: Nagyon pozitív szemléletű értékelés Típus: Mindig van legalább egy jó válasz (N/1..N) Source: http://scjptest.com 1. Given the code. What is the result? public class Hotel { Thread 2:12 private static void book() { System.out.print("book"); public static void main(string[] args) throws Interruptedxception { Thread.sleep(1); book(); "book" is printed ompilation fails. The code executes normally, but nothing is printed. n exception is thrown at runtime. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 1/24
TestLine - SJP sample 2. import java.util.ollection; import java.util.hashmap; import java.util.map.ntry; import java.util.set; public class StringToInteger { HashMap hm = new HashMap(); public void add(string a, Integer b) { hm.put(a, b); public Set getkeys() { return hm.keyset(); public [..PL..] getvalues() { return hm.values(); public Set getntries() { return hm.entryset(); public static void main(string args[]) { StringToInteger si = new StringToInteger(); si.add("one", 1); si.add("two", 2); System.out.println(si.getKeys()); System.out.println(si.getValues()); System.out.println(si.getntries()); Map 3:02 ollection Set ollection Set sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 2/24
TestLine - SJP sample 3. Which code, inserted inserted at line labeled "//some code goes her", allows the class Test to be compiled? class Util { public enum State{TIV, LT, INTIV Inner class 2:14 public class Test { public static void main(string args[]) { //some code goes here State state = Util.INTIV; State state = State.INTIV; State state = INTIV; Util.State state = Util.State.INTIV; sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó 4. Given the code. What is the result? public static void main(string args[]) { Object myobj = new String[]{"one", "two", "three" { for (String s : (String[])myObj) System.out.print(s + "."); String 2:07 n exception is thrown at runtime. ompilation fails because of an error at line 2 one.two.three. ompilation fails because of an error at line 3 sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 3/24
TestLine - SJP sample 5. ollection 2:38 Given the code. What is the result? import java.util.ollections; import java.util.iterator; import java.util.linkedlist; import java.util.list; public class TryMe { public static void main(string args[]) { List list = new LinkedList(); list.add("one"); list.add("two"); list.add("three"); ollections.reverse(list); Iterator iter = list.iterator(); for (Object o : iter) { System.out.print(o + " "); "three two one " is printed Nothing is printed "one two three " is printed ompilation fails n exception is thrown at runtime sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 4/24
TestLine - SJP sample 6. Given the code. What is the result? public class TryMe { oolean 2:14 public static void print(string str) { System.out.print(oolean.valueOf(str)? "true" : "false"); public static void main(string args[]) { print("tru"); print("false"); "falsefalse" is written. ompilation fails. "truefalse" is written. n exception is thrown at runtime. "truetrue" is written. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó 7. Which is true? (select two) import static java.lang.math.abs; static import java.lang.math; import static java.lang.math; import static java.lang.math.*; static import java.lang.math.*; sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó Import 1:48 TestLine - SJP sample oldal 5/24
TestLine - SJP sample 8. Given the code. What is the output? public static void main(string args[]) { Object myobj = new String[]{"one", "two", "three";{ for (String s : (String[])myObj) System.out.print(s + "."); String 1:39 n exception is thrown at runtime. one.two.three. ompilation fails because of an error at line 3 ompilation fails because of an error at line 2 sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 6/24
TestLine - SJP sample 9. Given the exhibit. What is the result? public class Hotel { Overload 2:30 public static void book(short a) { System.out.print("short "); public static void book(short a) { System.out.print("SHORT "); public static void book(long a) { System.out.print("LONG "); public static void main(string[] args) { short shortroom = 1; int introom = 2; book(shortroom); book(introom); ompilation fails short LONG n exception is thrown at runtime SHORT LONG sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 7/24
TestLine - SJP sample 10. Given the code. What is the result? public class Somelass { private int value = 1; Parameter 2:22 public int getvalue() { return value; public void changeval(int value) { value = value; public static void main(string args[]) { int a = 2; Somelass c = new Somelass(); c.changeval(a); System.out.print(c.getValue()); ompilation fails n exception is thrown at runtime "1" is printed "2" is printed sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 8/24
TestLine - SJP sample 11. Give the code. What is the result? class Hotel { public int bookings; public void book() { bookings++; Hotel 2:00 public class SuperHotel extends Hotel { public void book() { bookings--; public void book(int size) { book(); super.book(); bookings += size; public static void main(string args[]) { SuperHotel hotel = new SuperHotel(); hotel.book(2); System.out.print(hotel.bookings); F 0 1 2 n exception is thrown at runtime. -1 ompilation fails. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 9/24
TestLine - SJP sample 12. Given the code. What is the output? public class Test { int a = 10; Parameter 2:02 public void dostuff(int a) { a += 1; System.out.println(a++); public static void main(string args[]) { Test t = new Test(); t.dostuff(3); 12 5 4 11 sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 10/24
TestLine - SJP sample 13. Given the code. What is the result? class Hotel { public int bookings; public void book() { bookings++; Override 2:30 public class SuperHotel extends Hotel { public void book() { bookings--; public void book(int size) { book(); super.book(); bookings += size; public static void main(string args[]) { Hotel hotel = new SuperHotel(); hotel.book(2); System.out.print(hotel.bookings); F n exception is thrown at runtime. ompilation fails. 2 1 0-1 sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 11/24
TestLine - SJP sample 14. Given the code. Which statements are true? (Select two) public class Hotel { Theory 2:23 public static void book() { //some code goes here public void cancelooking() { //some code goes here Hotel.cancelooking() is a valid invocation of cancelooking() Method book() can directly call method cancelooking() Method cancelooking() can directly call method book() Hotel.book() is a valid invocation of book() sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó 15. Given the code. What is true? public class Room { public int roomnr; private ate begintm; private ate endttm; Theory 2:23 public void book(int roomnr, ate beginttm, ate endttm) { this.roomnr = roomnr; this.begintm = beginttm; this.endttm = endttm; The method book breaks encapsulation. The class is fully encapsulated. The variable roomnr breaks encapsulation. The code demonstrates polymorphism. Variables beginttm and endttm break polymorphism. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 12/24
TestLine - SJP sample 16. Given the code. What is the output? public class Hotel { private int roomnr; Theory 2:54 public Hotel(int roomnr) { this.roomnr = roomnr; public int getroomnr() { return this.roomnr; static Hotel dostuff(hotel hotel) { hotel = new Hotel(1); return hotel; public static void main(string args[]) { Hotel h1 = new Hotel(100); System.out.print(h1.getRoomNr() + " "); Hotel h2 = dostuff(h1); System.out.print(h1.getRoomNr() + " "); System.out.print(h2.getRoomNr() + " "); h1 = dostuff(h2); System.out.print(h1.getRoomNr() + " "); System.out.print(h2.getRoomNr() + " "); 100 100 100 1 1 100 100 100 100 100 100 100 1 1 1 100 100 100 100 1 100 1 1 1 1 sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 13/24
TestLine - SJP sample 17. Generic 2:58 Given the code. Select correct calls of methods. (Select all that apply) import java.util.*; class mpty { class xtended extends mpty { public class TryMe { public static void dostuff1(list list) { // some code public static void dostuff2(list list) { // some code public static void dostuff3(list F dostuff2(list2); dostuff2(list1); dostuff1(list2); dostuff1(list1); dostuff3(list1); dostuff3(list2); sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 14/24
TestLine - SJP sample 2017.01.10. 19:39:23 18. Given the code. What is the result? import java.util.*; public class TryMe { public static void main(string args[]) { Queue q = new PriorityQueue(); q.add("3"); q.add("1"); q.add("2"); System.out.print(q.poll() + " "); System.out.print(q.peek() + " "); System.out.print(q.peek()); Queue 2:13 F 1 1 2 1 2 2 3 1 1 3 2 1 2 3 3 1 2 3 sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 15/24
TestLine - SJP sample 2017.01.10. 19:39:23 19. Given the code. What is the result? public class ruiser implements Runnable { Thread 2:14 public void run() { System.out.print("go"); public static void main(string arg[]) { Thread t = new Thread(new ruiser()); t.run(); t.run(); t.start(); "gogo" is printed ompilation fails. "go" is printed "gogogo" is printed n exception is thrown at runtime. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 16/24
TestLine - SJP sample 2017.01.10. 19:39:23 20. Given the code. What is the result? public class ruiser implements Runnable { public static void main(string[] args) { Thread a = new Thread(new ruiser()); a.start(); Thread 2:22 System.out.print("egin"); a.join(); System.out.print("nd"); public void run() { System.out.print("Run"); "eginnd" is printed. "eginndrun" is printed. n exception is thrown at runtime. "eginrunnd" is printed. ompilation fails. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó 21. Given the code. What is the result? public static void main(string args[]) { String str = null; if (str == null) { System.out.print("1"); else (str.length() == 0) { System.out.print("2"); else { System.out.print("3"); String 2:07 "1" is printed. ompilation fails. "2" is printed. "3" is printed. n exception is thrown at runtime. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 17/24
TestLine - SJP sample 2017.01.10. 19:39:23 22. Given the code. What is the result? import java.util.hashset; public class HashTest { private String str; public HashTest(String str) { this.str = str; public static void main(string args[]) { HashTest h1 = new HashTest("1"); HashTest h2 = new HashTest("1"); String s1 = new String("2"); String s2 = new String("2"); HashSet hs = new HashSet(); hs.add(h1); hs.add(h2); hs.add(s1); hs.add(s2); System.out.print(hs.size()); Hash 2:43 n exception is thrown at runtime. ompilation fails. "2" is printed. "3" is printed. "4" is printed. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 18/24
TestLine - SJP sample 2017.01.10. 19:39:23 23. Given the code. What is the result? public class Somelass { private int value = 1; Parameter 2:12 public void printval(int value) { System.out.print(value); public static void main(string args[]) { int a = 2; Somelass c = new Somelass(); c.printval(a); "2" is printed n exception is thrown at runtime "1" is printed ompilation fails sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 19/24
TestLine - SJP sample 2017.01.10. 19:39:23 24. Generic 2:23 Given the code. What is the result? public class TrickyNum { private X x; public TrickyNum(X x) { this.x = x; private double getouble() { return x.doublevalue(); public static void main(string args[]) { TrickyNum a = new TrickyNum(new Integer(1)); System.out.print(a.getouble()); ompilation fails. n exception is thrown at runtime. "1" is printed. "1.0" is printed. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 20/24
TestLine - SJP sample 2017.01.10. 19:39:23 25. Given the code. What is the result? public static void main(string args[]) { String str = null; if (str.length() == 0) { System.out.print("1"); else if (str == null) { System.out.print("2"); else { System.out.print("3"); String 2:07 "2" is printed. n exception is thrown at runtime. "1" is printed. "3" is printed. ompilation fails. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 21/24
TestLine - SJP sample 2017.01.10. 19:39:23 26. Generic 2:24 Given the code. What is the result? public class TrickyNum { private X x; public TrickyNum(X x) { this.x = x; private double getouble() { return ((ouble) x).doublevalue(); public static void main(string args[]) { TrickyNum a = new TrickyNum(new Integer(1)); System.out.print(a.getouble()); "1.0" is printed. n exception is thrown at runtime. ompilation fails. "1" is printed. sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 22/24
TestLine - SJP sample 2017.01.10. 19:39:23 27. Which piece of code will allow this class to be correctly serialzed and desirialized? import java.io.*; Serialization 2:43 public class ar implements Serializable { public int speeds; public int wheels; private void writeobject(objectoutputstream oos) throws IOxception { oos.writeint(speeds); oos.writeint(wheels); private void readobject(objectinputstream ois) throws IOxception { [Place here] this = ois.defaultreadobject(); wheels = ois.readint(); speeds = ois.readint(); speeds = ois.readint(); wheels = ois.readint(); ois.defaultreadobject(); sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó 28. Given the code. What is the result? int i = 10; while (++i ycle 1:46 12 Line 5 will be never reached. 10 11 sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 23/24
Powered by TPF (www.tcpdf.org) TestLine - SJP sample 2017.01.10. 19:39:23 29. When comparing java.io.ufferedwriter to java.io.filewriter, which capability exist as a method in only one of the two? flushing the stream losing the stream writing to the stream writing a line separator to the stream marking a location in the stream sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó Stream 1:55 30. Given the code. What is the result? public class Hotel { Thread 1:42 private static void book() { System.out.print("book"); public static void main(string[] args) throws Interruptedxception { Thread.sleep(1); book(); The code executes normally, but nothing is printed. ompilation fails. n exception is thrown at runtime. "book" is printed sak tipp Talán jó Nem válaszolok Valószínűleg jó iztosan jó TestLine - SJP sample oldal 24/24