NEWS & UPDATES >> BCA BCSP064 Synopsis & Project Work Started for DEC 2017, IGNOU MCA MCSP060 Synopsis Work Started for DEC 2017, CONTACT 4 IGNOU Mini Project

IGNOU BCA MCA Students - VIVA Question Answer for JAVA or JSP Part III

IGNOU BCA MCA Students - VIVA Question Answer for JAVA or JSP

JAVA or JSP Selected Question Answer - PART III


8. Does Java support multiple inheritance ? No, Java does not support multiple inheritance. Each class is able to extend only on one class, but is able to implement more than one interfaces.
9. What is the difference between an Interface and an Abstract class ? Java provides and supports the creation both of abstract classes and interfaces. Both implementations share some common characteristics, but they differ in the following features:
·         All methods in an interface are implicitly abstract. On the other hand, an abstract class may contain both abstract and non-abstract methods.
·         A class may implement a number of Interfaces, but can extend only one abstract class.
·         In order for a class to implement an interface, it must implement all its declared methods. However, a class may not implement all declared methods of an abstract class. Though, in this case, the sub-class must also be declared as abstract.
·         Abstract classes can implement interfaces without even providing the implementation of interface methods.
·         Variables declared in a Java interface is by default final. An abstract class may contain non-final variables.
·         Members of a Java interface are public by default. A member of an abstract class can either be private, protected or public.
·         An interface is absolutely abstract and cannot be instantiated. An abstract class also cannot be instantiated, but can be invoked if it contains a main method.
Also check out the Abstract class and Interface differences for JDK 8.

10. What are pass by reference and pass by value ? When an object is passed by value, this means that a copy of the object is passed. Thus, even if changes are made to that object, it doesn’t affect the original value. When an object is passed by reference, this means that the actual object is not passed, rather a reference of the object is passed. Thus, any changes made by the external method, are also reflected in all places.
Java Threads
11. What is the difference between processes and threads ? A process is an execution of a program, while aThread is a single execution sequence within a process. A process can contain multiple threads. A Thread is sometimes called a lightweight process.

12. Explain different ways of creating a thread. Which one would you prefer and why ? There are three ways that can be used in order for a Thread to be created:
·         A class may extend the Thread class.
·         A class may implement the Runnable interface.
·         An application can use the Executor framework, in order to create a thread pool.
The Runnable interface is preferred, as it does not require an object to inherit the Thread class. In case your application design requires multiple inheritance, only interfaces can help you. Also, the thread pool is very efficient and can be implemented and used very easily.
13. Explain the available thread states in a high-level. During its execution, a thread can reside in one of the following states:
·         NEW: The thread becomes ready to run, but does not necessarily start running immediately.
·         RUNNABLE: The Java Virtual Machine (JVM) is actively executing the thread’s code.
·         BLOCKED: The thread is in a blocked state while waiting for a monitor lock.
·         WAITING: The thread waits for another thread to perform a particular action.
·         TIMED_WAITING: The thread waits for another thread to perform a particular action up to a specified waiting time.
·         TERMINATED: The thread has finished its execution.


14. What is the difference between a synchronized method and a synchronized block ? In Java programming, each object has a lock. A thread can acquire the lock for an object by using the synchronized keyword. The synchronized keyword can be applied in a method level (coarse grained lock) or block level of code (fine grained lock).

No comments:

Post a Comment