TestLine - SCJP sample Minta feladatsor

Hasonló dokumentumok
Java bevezet o Kab odi L aszl o Kab odi L aszl o Java bevezet o

Collections. Összetett adatstruktúrák

Gelle Kitti Algoritmusok és adatszerkezetek gyakorlat - 07 Hasítótáblák

Java és web programozás

List<String> l1 = new ArrayList<String>(); List<Object> l2 = l1; // error

Kivételek kezelése (exception handling) Hibakezelés old style. Kivételkezelés

Segédanyag: Java alkalmazások gyakorlat

C# nyelv alapjai. Krizsán Zoltán 1. Objektumorientált programozás C# alapokon tananyag. Általános Informatikai Tanszék Miskolci Egyetem

Dinamikus adatszerkezetek. 2D generikus tömb: C++ 2D generikus tömb: C++

Dinamikus adatszerkezetek. 2D generikus tömb: C++ 2D generikus tömb: C++ 2D tömb: Java versus C++ 2D tömb: Java.


Programozási nyelvek Java

Az új be- és kimenet könyvtár

Helyes-e az alábbi kódrészlet? int i = 1; i = i * 3 + 1; int j; j = i + 1; Nem. Igen. Hányféleképpen lehet Javaban megjegyzést írni?

Java programozási nyelv

Segédanyag: Java alkalmazások gyakorlat

abkezel.java import java.awt.*; import java.awt.event.*; import javax.swing.*; import java.sql.*; public class abkezel extends JFrame {

C# osztályok. Krizsán Zoltán

Az emelt szintű. informatika érettségi. programozási feladatainak. megoldása Java nyelven. NetBeans IDE 8.1 környezetben

Az osztályok csomagokba vannak rendezve, minden csomag tetszőleges. Könyvtárhierarhiát fed: Pl.: java/util/scanner.java

Bánsághi Anna

JAVA PROGRAMOZÁS 3.ELŐADÁS

Programozási nyelvek II.: JAVA

OOP: Java 8.Gy: Abstract osztályok, interfészek

Java és web programozás

Objektum Orientált Programozás. 11. Kivételkezelés 44/1B IT MAN

Algoritmusok és adatszerkezetek II.

ZH mintapélda. Feladat. Felület

Grafikus felhasználói felületek. Abstract Window Toolkit, a java.awt és java.awt.event csomagok

Vé V g é r g e r h e a h j a tá t s á i s s z s ál á ak a Runnable, Thread

Segédanyag: Java alkalmazások gyakorlat

TestLine - SCJP sample 3 Minta feladatsor

SZERVER OLDALI JAVASCRIPT. 3. hét Javascript nyelvi elemek

Magas szintű programozási nyelvek 2 Előadás jegyzet

Java Programozás 1. Gy: Java alapok. Ismétlés ++

Szoftvertechnológia alapjai Java előadások

Objektumorientált programozás C# nyelven

Se S r e ial a iza z t a ion o n (in n Ja J v a a v ) a Szerializáció

Delegátumok C#-ban Krizsán Zoltán iit

Reader /Writer InputStreamReader, OutputStreamWriter

Java osztálykönyvtár és használata

Objektumorientált programozás C# nyelven III.

Programozási nyelvek Java

Programozás I. Első ZH segédlet

Kivételkezelés, naplózás. Exception handling, logging

Programozás BMEKOKAA146. Dr. Bécsi Tamás 1. Előadás

Programozási nyelvek II.: JAVA

Java VI. Egy kis kitérő: az UML. Osztály diagram. Általános Informatikai Tanszék Utolsó módosítás:

BME MOGI Gépészeti informatika 4.

Mi a különbség az extends és az implements között. Mikor melyiket kell használni? Comperable-t megvalósító oasztályokban össze lehet hasonlitani

CREATE TABLE student ( id int NOT NULL GENERATED ALWAYS AS IDENTITY PRIMARY KEY, name varchar(100) NOT NULL, address varchar(100) NOT NULL )

Java Programozás 3. Gy: Java GUI. Swing, AWT

Szoftvertechnológia alapjai Java előadások

OOP: Java 8.Gy: Gyakorlás

Programozási technológia

Programozási nyelvek és módszerek Java Thread-ek

Modern unit és integrációs tesztelés

117. AA Megoldó Alfréd AA 117.

INFORMATIKAI ALAPISMERETEK

Újdonságok a Java nyelvben

Számítástechnika I. BMEKOKAA152 BMEKOKAA119 Infokommunikáció I. BMEKOKAA606. Dr. Bécsi Tamás

Objektumorientált programozás C# nyelven

OOP: Java 11.Gy: Enumok, beágyazott osztályok. 13/1 B ITv: MAN

OOP: Java 7.Gy: Öröklődés, referenciák

OBJEKTUM ORIENTÁLT PROGRAMOZÁS JAVA NYELVEN. vizsgatételek

Kalapácsvetés 2016 szöveges

Stateless Session Bean

Széchenyi István Egyetem

INFORMATIKAI ALAPISMERETEK

Java és web programozás

Pelda öröklődésre: import java.io.*; import java.text.*; import java.util.*; import extra.*;

Java Programozás 11. Ea: MVC modell

(NGB_TA024_1) MÉRÉSI JEGYZŐKÖNYV

I. 288.: Utcai WiFi térkép

Java IX. telkezelés a Java-ban

Algoritmusok és adatszerkezetek II.

Adatbázis alapú rendszerek gyakorlat Adatbázis alapú alkalmazásfejlesztés Java, C# környezetben

Programozási nyelvek Java

C# versus Java. Óbudai Egyetem, Java Standard Edition Mérnök Informatikus szak, BSc Labor 3. Bedők Dávid v0.4

Java IX. telkezelés a Java-ban

C#, OOP. Osztályok tervezése C#-ban

Osztályszintű elérés, kivételkezelés, fájlkezelés

Programozási technológia

VB C++ C# JScript J# Common Language Specification. ADO.NET and XML. Base Class Library. Common Language Runtime. Operating System

BME MOGI Gépészeti informatika 8.

Java Remote Method Invocation API

Java Programozás 4. Gy: Java GUI. Tipper, MVC kalkulátor

Java 5. Ráth István

7. K: JAVA alapok Konzultáció

Generikus osztályok, gyűjtemények és algoritmusok

Programozási technológia

Osztályok. construct () destruct() $b=new Book(); $b=null; unset ($b); book.php: <?php class Book { private $isbn; public $title;

PHP II. WEB technológiák. Tóth Zsolt. Miskolci Egyetem. Tóth Zsolt (Miskolci Egyetem) PHP II / 19

Java Programozás 9. Gy: Java alapok. Adatkezelő 5.rész

Fejezetek az "Effective Java" c. könyvből

Kölcsönös kizárás, atomicitás, szemafor.

OOP: Java 4.Gy: Java osztályok

Programozás I. 3. gyakorlat. Szegedi Tudományegyetem Természettudományi és Informatikai Kar

Sikeres végrehajtás(pass): ez azt jelenti, hogy a teszt rendben lefutott, és az ellenőrzési feltételek mind teljesültek.

Java és web programozás

Átírás:

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