Tuesday 3 October 2017

Interview/Viva Questions on Advanced Java

                      Following is the list of Interview / Viva questions on Advanced Java which can be asked in Job interviews or Oral exams:



1. What is the significance or what is the use of these data structures in Java: Enumeration, BitSet, Vector, Stack, Dictionary, Hashtable, Properties.
Ans: Check link https://www.tutorialspoint.com/java/java_data_structures.htm

2. What is the similarity between HashMap, Hashtable and Properties data stuctures?
Ans: HashMap, Hashtable, Properties, all these data structures are used to save data in terms of pair (Key, Value). 

Though, they are used for same purpose, there are some differences in their working.

3. What is the difference between HashMap and Hashtable data stuctures?
Ans: HashMap data structures are not synchronized while Hashtable data structures can be synchronized among the different threads.

4. How Properties data structure is different from HashMap and Hashtable data stuctures?
Ans: Properties data structure saves the values in terms of Key-Value pairs like HashMap and Hashtable; but Properties have some extra features like, Properties class has some methods by which we can save its values into text or xml file. Also we can read values from text or xml file and allocate them to Properties.

5. What is Collections Framework in Java?
Ans: Check Link https://www.comrevo.com/2018/07/What-is-Collections-Framework-in-Java.html 

6. What is the difference between List and Set data structures?
Ans: List allows duplicate elements; in the sense, List can have same element multiple times. Set does not have duplicate elements i.e. all elements of Set are unique.

7. What is the difference between HashSet, LinkedHashSet and TreeSet data structures?

Ans: Set inteface is implemented in classes HashSet, LinkedHashSet, TreeSet. All these classes stores unique elements. HashSet stores the elements in random sequence. LinkedHashSet stores the elements in the order of their insertion. TreeSet stores the elements in their increasing order.  

8. What is the difference between HashMap, LinkedHashMap and TreeMap data structures?

Ans: Map interface is implemented in classes HashMap, LinkedHashMap, TreeMap. All these classes stores elements in terms of key-value pair. HashMap stores the elements in random sequence. LinkedHashMap stores the elements in the order of their insertion. TreeMap stores the elements in increasing order of keys.

9. What is Generics in Java? 
Ans: Check Link https://www.tutorialspoint.com/java/java_generics.htm

10. What is Socket? 
Ans: In computer network, socket is an end point for sending and receiving data. It is combination of IP address and Port number.

11. Explain the different types of Sockets (Stream Sockets, Datagram Sockets, Raw Sockets, Sequenced Packet Sockets).
Ans: Stream Sockets: They are also known as Connection-oriented sockets. They uses TCP (Transmission Control Protocol), SCTP (Stream Control Transmission Protocol), DCCP (Datagram Congestion Control Protocol).
Datagram Sockets: They are also known as Connection-less Sockets. They uses UDP (User Datagram Protocol).  
Raw Sockets: They are used in routers. Here, transport layer is bypassed i.e. there in no port number, only IP address.
Sequenced Packet Sockets: They are similar to Stream sockets with the exception that record boundaries are preserved. 

12. What do you mean by Port Number? What is the size of port number (in terms of bits)? 
Ans: Port numbers are 16 bit unsigned integers.

13. What are the different types of port numbers? What is their range?
Ans: 0 to 1023 (Well Known Ports): these port numbers are reserved by IANA for special services e.g. FTP: 20 & 21, Telnet: 23, HTTP: 80
1024 to 49151 (Registered Ports): these port numbers can be registered by companies / organisations with IANA. e.g. Mysql uses port number 3306, Apache Tomcat uses: 8080
49152 to 65535 (Dynamic or Private Ports): These ports can not be be registered with IANA. These port numbers can be used by anyone for their applications.

14. Explain the differences between Connection oriented (TCP) and Connection less (UDP) services?
Ans: Check link https://www.comrevo.com/2019/07/difference-between-tcp-and-udp.html

15. What are the Socket primitives (APIs) on Client side and on Server side in connection oriented / connection less services? 
(e.g. bind(), listen() etc.) 
Ans:
Connection Oriented Services: 
Server: socket(), bind(), listen(), accept(), receive(), send(), close()
Client: socket(), bind(), connect(), send(), receive(), close()

Connection-less Services:
Server: socket(), bind(), recvfrom(), sendto(), 
Client: socket(), bind(), sendto(), recvfrom(), close()

16. How Socket programming is implemented in Java? Which package should be imported? Which Java Classes are used?
Ans: Check Links: 

TCP Client Server Program in Java (Socket Programming)
https://www.comrevo.com/2019/07/tcp-client-server-program-in-java-socket-programming.html

UDP Client Server Program in Java (Socket Programming)
https://www.comrevo.com/2019/07/udp-client-server-program-in-java-socket-programming.html

Client Server chat program (application) in Java using Socket Programming 
https://www.comrevo.com/2019/07/client-server-chat-program-application-in-java-using-socket-programming.html   

17. What is Serialization?
Ans: Check Link: http://www.comrevo.com/2017/08/serialization-in-java-with-example.html

18. What is the need of Serialization?  
Ans: Check Link: http://www.comrevo.com/2017/08/serialization-in-java-with-example.html

19. What is Deserialization? 
Ans: Check Link: http://www.comrevo.com/2017/08/serialization-in-java-with-example.html

20. How Serialization is achieved in Java? 

Ans: Check Link: http://www.comrevo.com/2017/08/serialization-in-java-with-example.html

21. What is JDBC?
Ans: JDBC stands for Java DataBase Connectivity. It is API for Java Programming Language which specifies how client connects to database.

22. What are the types of JDBC drivers? 
Ans: Check Link: http://www.comrevo.com/2017/07/what-are-types-of-jdbc-drivers.html

23. What are the basic steps in jdbc starting from connection with database to the execution of SQL queries? 
Ans: Check Link: http://www.comrevo.com/2017/07/basic-steps-in-jdbc-code.html

24. Which package should be imported in JDBC Java program?
Ans: java.sql.* 
Note: Check sample jdbc program to retrieve data from MySQL database http://www.comrevo.com/2017/07/jdbc-code-to-retrieve-data-from-mysql-database.html .

25. What is port number used by MySQL database?
Ans: 3306

26. Explain some basic SQL queries with their syntaxes?
Ans: Check Link: http://www.comrevo.com/2015/12/mysql-tutorial-basic-sql-queries.html

27. What is the need of Prepared Statement? How to use it?
Ans: Check Link: https://www.comrevo.com/2019/07/java-mysql-insert-example-using-prepared-statement.html 

28. What is the need of Callable Statement? How to use it?
Ans: Check Link: https://www.comrevo.com/2019/07/java-mysql-callablestatement-example-or-java-mysql-call-stored-procedure-example.html 

29. What are the different phases in Thread Life Cycle?
Ans: Newborn: New thread is created.
Running: Thread is running on processor core.
Runnable: Thread is waiting for the access of processor core.
Blocked: Thread is suspended.
Dead: Execution of thread is stopped.

30. What are the two ways of creating threads in Java?
Ans: Check Link http://www.comrevo.com/2016/01/how-to-create-threads-in-java.html

31. What is Thread Pool concept in Java?
Ans: Check Link http://www.comrevo.com/2017/07/thread-pool-in-java-with-example.html 

32. What is the advantage of Thread Pool? 
Ans: Check Link http://www.comrevo.com/2017/07/thread-pool-in-java-with-example.html

33. What is ExecutorService? How it is used to create pool of threads? 
Ans: Check Link http://www.comrevo.com/2017/07/thread-pool-in-java-with-example.html 

34. How multi-threading synchronization is achieved in Java?
Ans: Check Link: https://www.comrevo.com/2018/09/multi-threading-synchronization-in-java-with-example-programs.html 

35. How multi-threading synchronization is achieved in Java using Synchronized block?
Ans: Check Link: https://www.comrevo.com/2018/09/multi-threading-synchronization-in-java-with-synchronized-block.html 

36. Explain the Life Cycle of Applet?
Ans: Check link https://www.comrevo.com/2018/10/life-cycle-of-applet.html

37. What is AppletViewer?
Ans: AppletViewer is command/program provided by Java. It is used to test applets. Applets are embedded in webpages. For this, web browsers should be Java enabled. If we don't have Java enabled web browsers, then AppletViewer is used to test applets. Though AppletViewer is used in place of web browser, it shows only the content mentioned in <applet></applet> tags.   

38. Which class provides paint() method?
Ans: public void paint(Graphics g) is used to redraw applet. It is given by Component class. Component class is given by package java.awt. 

39. What is Swing in Java? 
Ans: Check Link: http://www.comrevo.com/2017/08/swing-in-java-with-example.html

40. How Swing is different from Applet?  
Ans: Check Link http://www.comrevo.com/2017/08/swing-in-java-with-example.html

41. Explain step by step methods to create Swing application? 
Ans: Check Link http://www.comrevo.com/2017/08/swing-in-java-with-example.html

42. What is the default Layout in Swing? 
Ans: CardLayout

43. What is the use of methods setVisible(), setSize(), setDefaultCloseOperation(), setLayout() in Swing? 
Ans: setVisible(): To make frame visible. For that, we need to pass parameter 'true'.
setSize(): To set the size of frame. We need to pass column, row size in pixels.
setDefaultCloseOperation(): To perform some operations when 'cross' botton on top corner of frame is clicked. 
To stop running Swing process when 'cross' button is clicked, we need to pass 3 or predefined constant 'JFrame.EXIT_ON_CLOSE' as parameter.
setLayout(): To set the layout of Swing frame, this method is called. e.g. setLayout(new FlowLayout()) to set FlowLayout. By default, there is CardLayout.

44. How events are handled in Swing using ActionListener interface?
Ans: Check Link: https://www.comrevo.com/2017/08/java-swing-program-for-addition-of-two-numbers.html 

45. How mouse events are handled in Swing using MouseListener interface?
Ans: Check Link: https://www.comrevo.com/2017/08/java-swing-mouselistener-example.html 

46. How mouse events are handled in Swing using MouseMotionListener interface?
Ans: Check Link: https://www.comrevo.com/2018/09/java-swing-mouse-motion-listener-example.html 

47. How Menu bar is added in Java Swing?
Ans: Check Link: https://www.comrevo.com/2018/09/java-swing-menu-bar-example.html 

48. How Progress Bar is added in Java Swing?
Ans: Check Link: https://www.comrevo.com/2018/09/swing-progress-bar-example.html 

49. How to use multiple frames in Java Swing?
Ans: Check Link: https://www.comrevo.com/2018/09/swing-multi-frame-example.html 

50. How to use multiple frames with progress bar in Java Swing?
Ans: Check Link: https://www.comrevo.com/2018/09/swing-multi-frame-progress-bar-example.html

                         Find Interview / Viva questions on Android Application Development in this link http://www.comrevo.com/2017/10/interview-questions-on-android-application-development.html.

No comments:

Post a Comment