0

programming languages Online Quiz - 337

Description: programming languages Online Quiz - 337
Number of Questions: 20
Created by:
Tags: programming languages
Attempted 0/20 Correct 0 Score 0

16.) To delete all the trailing spaces of each line of file test1

  1. a) sed 's/[ ][^ ]*$//' test2

  2. b) sed 's/[ ][ ]*$//' test2

  3. c) sed 's/[ ][ ]*$/' test2

  4. d) sed 's/[ ][ $]*$//' test2


Correct Option: A

17.) How to duplicate file descriptors?

  1. a) duplicate()

  2. b) dup()

  3. c) cp()

  4. d) mknod()


Correct Option: B

18.) What is the difference between at & cron?

  1. a) Both are Unix scheduling utilities

  2. b) at is restricted one and crontab is not restricted

  3. c) No difference

  4. d) at takes input from user while cron takes from a confiuration file


Correct Option: D

19.) How to remove a queued file from the printer queue?

  1. a) lpqrm

  2. b) lprm

  3. c) jobs -r

  4. d) lpc -rm


Correct Option: B

20.) If inet service is restarted, all the open sockets gets closed

  1. a) True

  2. b) False

  3. c)

  4. d)


Correct Option: B

21.) The difference between telnet & rsh?

  1. a) telnet works only with terminals where rsh works for all

  2. b) telnet is unix product while rsh is a TCP product

  3. c) telnet uses byte protocol while rsh uses stream protocol

  4. d) No difference. They can be used interchangably


Correct Option: C

What does session.evict() method do ?

  1. a) remove the object and its collections from the first level cache

  2. b) remove the object and its collections from the second level cache

  3. c) remove the object and its collections from the data base

  4. d) None of the above


Correct Option: A

AI Explanation

To answer this question, you need to understand the concept of caching in Hibernate.

The session.evict() method is used to remove an object and its collections from the first level cache, also known as the session cache.

Option A) Remove the object and its collections from the first level cache - This option is correct. When the session.evict() method is called, the object and its collections are removed from the first level cache, which means that subsequent operations on the object will not be tracked by the cache.

Option B) Remove the object and its collections from the second level cache - This option is incorrect. The session.evict() method does not directly remove the object and its collections from the second level cache. The second level cache is a separate cache that is shared among multiple sessions.

Option C) Remove the object and its collections from the database - This option is incorrect. The session.evict() method does not delete the object and its collections from the database. It only removes them from the first level cache.

Option D) None of the above - This option is incorrect. The correct answer is option A.

Therefore, the correct answer is A) Remove the object and its collections from the first level cache. This option is correct because the session.evict() method is used to remove an object and its collections from the first level cache.

22.) Unix shell scripting does not support floating points directly

  1. a) True

  2. b) False

  3. c)

  4. d)


Correct Option: A

Which is simplest code snippet you will add in the below main function to set the name attribute of 50th in the ItemList to “Done”? import java.util.ArrayList; import java.util.List; class Item { public int code; public String name; public Item(String name) { this.name = name; } } public class Main { public static void main(String args[]) { List itemList = new ArrayList(); for (int i = 0; i < 50; i++) { Item im = new Item("Test"); itemList.add(im); } //Code to change name of the 50th object to “Done” } }

  1. im.name = "Done";

  2. Item otherObject = new Item(“Done”); itemList.set(49, otherObject);

  3. ((Item)itemList.get(49)).name = “Done”;

  4. None of above is correct as they are not changing 50th element.


Correct Option: A

23.) Is it possible to process return value of system()?

  1. a) Yes

  2. b) No

  3. c)

  4. d)


Correct Option: A

Is the Session threadsafe in Hibernate ?

  1. a) TRUE

  2. b) FALSE

  3. c) no matter

  4. d) none of the above


Correct Option: B

24.) lpc command is used to

  1. a) Add printer and queues

  2. b) Add modem & flash drive

  3. c) Add printer alone

  4. d) Invalid command


Correct Option: A

How can you make a property be read from the database but not modified in anyway

  1. a) By using the insert="false" and update="false" attributes.

  2. b) By using the isinsert="false" and isupdate="false" attributes.

  3. c) By using the isinsert="no" and isupdate="no" attributes

  4. d) None


Correct Option: A

25.) How to send signals to other processes?

  1. a) Use sigsend()

  2. b) use kill()

  3. c) use signal()

  4. d) Only init can send signals


Correct Option: B

Which statement is correct ?

  1. a) A Session will not obtain a JDBC Connection (or a Datasource) unless it is needed

  2. b) A Session will obtain a JDBC Connection (or a Datasource) on object create

  3. c) A Session has no relation with JDBC Connection (or a Datasource)

  4. d) none of the above


Correct Option: A

How to enable query cache in hibernate

  1. a) hibernate.cache.query_cache true

  2. b) hibernate.cache.use_query_cache true

  3. c) hibernate.cache.query_cache yes

  4. d) none


Correct Option: B

If you are not certain that a matching row exists in the database then which method is the best ?

  1. a) Session.load();

  2. b) Session.get();

  3. c) Session.fetch();

  4. d) None of the above


Correct Option: B

AI Explanation

To answer this question, you need to understand the different methods used to retrieve data from a database using the Hibernate framework.

Option A) Session.load() - This option is incorrect because the load() method in Hibernate throws an exception if the matching row does not exist in the database. It assumes that the requested data will always be present in the database.

Option B) Session.get() - This option is correct because the get() method in Hibernate returns null if the matching row does not exist in the database. It does not throw an exception and provides a safe way to handle cases where the requested data may or may not be present.

Option C) Session.fetch() - This option is incorrect because there is no fetch() method in the Hibernate Session class. It is not a valid method.

Option D) None of the above - This option is incorrect because Option B (Session.get()) is the correct method to use when you are not certain that a matching row exists in the database.

The correct answer is B) Session.get(). This option is correct because it returns null if the matching row does not exist in the database, making it the best method to use when you are not certain about the presence of the data.

Which statement is correct?

  1. a) bag has index column

  2. b) bag permits duplicate element values

  3. c) bag does not permits duplicate element values

  4. d) None


Correct Option: B
Explanation:

To solve this question, the user needs to have knowledge about the concept of a bag data structure. A bag is a collection of unordered elements that may contain duplicates.

Now, let's go through each option and explain why it is right or wrong:

a) bag has index column: This statement is incorrect. A bag is an unordered collection, which means it does not have an index column. Items in a bag are stored in any order.

b) bag permits duplicate element values: This statement is correct. A bag allows duplicate elements to be added to it. For example, a bag can contain two or more items with the same value.

c) bag does not permit duplicate element values: This statement is incorrect. A bag permits duplicate elements to be added to it. Therefore, this statement is false.

d) None: This option is incorrect because option B is correct.

The Answer is: B

It is possible to re-load an object and all its collections at any time, using the xxxx() method. This is useful when database triggers are used to initialize some of the properties of the object.What is the xxxx() method ?

  1. a) refresh();

  2. b) flush();

  3. c) fetch();

  4. d) load()


Correct Option: A

What is the root level element in a hibernate mapping file?

  1. a)

  2. b)

  3. c)

  4. d) None


Correct Option: C
- Hide questions