Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Skip to main content
- Vstupní test - JAVA programátor
- You are logged in as Matej Racinsky (Logout)
- Page path
- Home / ► My courses / ► JAVA / ► Topic 1 / ► Vstupní test - JAVA programátor
- Started on Monday, 27 April 2015, 10:31 PM
- State Finished
- Completed on Tuesday, 28 April 2015, 12:00 AM
- Time taken 1 hour 29 mins
- Grade Not yet graded
- Question 1
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Jak provedete konvert hodnoty String reprezentující datum na Date
- String dateString = "2010-01-11";
- answer:
- DateFormat format = new SimpleDateFormat("yyyy-mm-dd");
- Date date = format.parse(dateString);
- Question 2
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Napište, jak provedete konvert hodnoty String reprezentující číslo na int
- String numString = "1000";
- answer:
- int number = Integer.parseInt(numString);
- Question 3
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Napište metodu, která vrátí datum Date posunutý odedneška o zadaný počet dní
- - příklad použití metody:
- Date date = getDateShift(100); // vrátí datum odedneška za 100 dní
- answer:
- public Date getDateShift(int shift) {
- Calendar calendar = Calendar.getInstance();
- calendar.add(Calendar.DATE, shift);
- return calendar.getTime();
- }
- Question 4
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Napište metodu, která vrátí int hodnotu na základě vstupního řetězce String dle tabulky:
- item_A 1
- item_B 3
- item_c 5
- item_D 7
- item_E 12
- item_F 4
- příklad použití metody:
- int itemId = itemNameToItemId("item_c");
- answer:
- public int itemNameToItemId(String item) {
- Map<String, Integer> map = new HashMap<>();
- map.put("item_A", 1);
- map.put("item_B", 3);
- map.put("item_c", 5);
- map.put("item_D", 7);
- map.put("item_E", 12);
- map.put("item_F", 4);
- return map.get(item);
- }
- Question 5
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Napište metodu, která převede čárkama oddělené hodnoty vstupního řetězce String na seznam hodnot
- příklad použití metody:
- List<String> itemList = convertStringSetToList("item_A, item_B, item_c, item_D, item_E, item_F");
- answer:
- public List<String> convertStringSetToList(String values){
- String[] valuesArray = values.split(", ");
- return Arrays.asList(valuesArray);
- }
- Question 6
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Jaký je rozdíl v použití operátoru & a && ?
- answer:
- operátor && provádí zkrácené vyhodnocování, tedy pokud ve výrazu A && B je A == false, B se nevyhodnocuje, zatímco u A & B se vyhodností A i B.
- Question 7
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Máme problém s JAVA HEAP (memory leak). Při analýze heap bylo zjištěno, že problém je někde v následujícím kódu. Identifikujte problém.
- Connection conn = null;
- PreparedStatement ps = null;
- ResultSet rs = null;
- try {
- conn = getConnection();
- ps = conn.prepareStatement(statement);
- rs = ps.executeQuery();
- if (rs.next()) {
- // code
- }
- } catch (Exception e) {
- // handle exception
- } finally {
- ps.close();
- conn.close();
- }
- answer:
- catch i finally jsou uvnitř bloku try. Takže když nastane výjimka, proměnné ps a re se nezavřou.
- Question 8
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Do kterého adresáře v ejb.jar archívu vložíte soubor ejb-jar.xml ?
- answer:
- do adresáře META-INF
- Question 9
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Vytvořte XSD schéma definující následující XML :
- <price_list>
- <price>
- <name>rohlík</name>
- <id>1</id>
- <currency>CZK</currency>
- <amount>3</amount>
- </price>
- <price>
- <name>mléko</name>
- <id>2</id>
- <currency>CZK</currency>
- <amount>12</amount>
- </price>
- <price>
- <name>máslo</name>
- <id>3</id>
- <currency>CZK</currency>
- <amount>25</amount>
- </price>
- <price>
- <name>chleba</name>
- <id>4</id>
- <currency>CZK</currency>
- <amount>21</amount>
- </price>
- </price_list>
- answer:
- <?xml version="1.0" encoding="UTF-8" ?>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="price_list">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="price" maxOccurs="unbounded">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="name" type="xs:string"/>
- <xs:element name="id" type="xs:integer"/>
- <xs:element name="currency" type="xs:string"/>
- <xs:element name="amount" type="xs:integer"/>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:schema>
- Question 10
- Complete
- Marked out of 1.00
- Not flaggedFlag question
- Question text
- Vytvořte XSD schéma definující následující XML :
- <price_list>
- <price name="rohlík" id="1" currency="CZK">3</price>
- <price name="mléko" id="2" currency="CZK">12</price>
- <price name="máslo" id="3" currency="CZK">25</price>
- <price name="chleba" id="4" currency="CZK">21</price>
- </price_list>
- answer:
- <?xml version="1.0" encoding="UTF-8" ?>
- <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema">
- <xs:element name="price_list">
- <xs:complexType>
- <xs:sequence>
- <xs:element name="price" maxOccurs="unbounded">
- <xs:complexType>
- <xs:simpleContent>
- <xs:extension base="xs:integer">
- <xs:attribute name="name" type="xs:string"/>
- <xs:attribute name="id" type="xs:integer"/>
- <xs:attribute name="currency" type="xs:string"/>
- </xs:extension>
- </xs:simpleContent>
- </xs:complexType>
- </xs:element>
- </xs:sequence>
- </xs:complexType>
- </xs:element>
- </xs:schema>
- Finish review
- Skip Quiz navigation
- Quiz navigation
- Question 1 This page Question 2 This page Question 3 This page Question 4 This page Question 5 This page Question 6 This page Question 7 This page Question 8 This page Question 9 This page Question 10 This page
- Finish review
- You are logged in as Matej Racinsky (Logout)
- JAVA
Advertisement
Add Comment
Please, Sign In to add comment