scretch.info Question Papers JAVA VIVA QUESTIONS AND ANSWERS PDF

JAVA VIVA QUESTIONS AND ANSWERS PDF

Wednesday, June 12, 2019 admin Comments(0)

Java Interview Questions i. Java Interview Questions .. Both implementations share some common characteristics, but they differ in the following features. Dear readers, these Java Interview Questions have been designed the subject and later they continue based on further discussion and what you answer −. Java Interview Questions and Answers. This interview section questions contains a brief introduction to the Java. It is intended as a tutorial on the Java, and.


Author:RAFAELA FLUMMER
Language:English, Spanish, Dutch
Country:France
Genre:Technology
Pages:253
Published (Last):30.03.2015
ISBN:713-8-70485-945-2
ePub File Size:15.47 MB
PDF File Size:9.45 MB
Distribution:Free* [*Sign up for free]
Downloads:48716
Uploaded by: ARIELLE

Java Viva Question and Answer. CONT: , Q. Why Java ? A. The programs that we are writing are very similar to their counterparts in. What are the various access specifiers for Java classes? Ans: In Java, access specifiers are the keywords used before a class name which. Java Interview Questions And Answers Pdf Yes, We can execute any code, even before the main method. We are using a static block.

Compile time polymorphism is method overloading whereas Runtime time polymorphism is done using inheritance and interface. So this brings us to the end of the Java interview questions blog. These set of Java Interview Questions will definitely help you ace your job interview. Good luck with your interview! Java Interview Questions and Answers Edureka.

Protected Protected can be accessed by the class of the same package, or by the sub-class of this class, or within the same class. Default Default are accessible within the package only. By default, all the classes, methods, and variables are of default scope. Private The private class, methods, or variables defined as private can be accessed within the class only.

Top 100 Java Interview Questions with Answers

The methods or variables defined as static are shared among all the objects of the class. The static is the part of the class and not of the object. The static variables are stored in the class area, and we do not need to create the object to access such variables. Therefore, static is used in the case, where we need to define variables or methods which are common to all the objects of the class. For example, In the class simulating the collection of the students in a college, the name of the college is the common attribute to all the students.

Therefore, the college name will be defined as static. There are various advantages of defining packages in Java.

Viva questions pdf answers java and

Packages avoid the name clashes. The Package provides easier access control. We can also have the hidden classes that are not visible outside and used by the package. It is easier to locate the related classes. Now, their sum 30 is treated as the string and concatenated with the string Javatpoint.

Therefore, the output will be 30Javatpoint. In the second case, the string Javatpoint is concatenated with 10 to be the string Javatpoint10 which will then be concatenated with 20 to be Javatpoint In the second case, The numbers 10 and 20 will be multiplied first to be because the precedence of the multiplication is higher than addition. The result will be treated as the string and concatenated with the string Javatpointto produce the output as Javatpoint However, they have been categorized in many sections such as constructor interview questions, static interview questions, Inheritance Interview questions, Abstraction interview question, Polymorphism interview questions, etc.

It is a programming paradigm based on objects having data and methods defined in the class to which it belongs.

Object-oriented paradigm aims to incorporate the advantages of modularity and reusability. Objects are the instances of classes which interacts with one another to design applications and programs.

+ TOP JAVA LAB VIVA Questions and Answers Pdf CSE VIVA Questions

There are the following features of the object-oriented paradigm. Follows the bottom-up approach in program design. Focus on data with methods to operate upon the object's data Includes the concept like Encapsulation and abstraction which hides the complexities from the user and show only functionality.

Implements the real-time approach like inheritance, abstraction, etc. The Object is the real-time entity having some state and behavior.

Pdf and java questions viva answers

In Java, Object is an instance of the class having the instance variables as the state of the object and the methods as the behavior of the object. The object of a class can be created by using the new keyword. There are the following basic differences between the object-oriented language and object-based language. Object-oriented languages follow all the concepts of OOPs whereas, the object-based language doesn't follow all the concepts of OOPs like inheritance and polymorphism.

Object-oriented languages do not have the inbuilt objects whereas Object-based languages have the inbuilt objects, for example, JavaScript has window object.

Examples of object-oriented programming are Java, C , Smalltalk, etc. All object references are initialized to null in Java.

The constructor can be defined as the special type of method that is used to initialize the state of an object. It is invoked when the class is instantiated, and the memory is allocated for the object. Every time, an object is created using the new keyword, the default constructor of the class is called. The name of the constructor must be similar to the class name. The constructor must not have an explicit return type. Based on the parameters passed in the constructors, there are two types of constructors in Java.

Default Constructor: default constructor is the one which does not accept any value. The default constructor is mainly used to initialize the instance variable with the default values.

It can also be used for performing some useful task on object creation.

2018 Latest 60 Java Interview Questions And Answers Pdf

A default constructor is invoked implicitly by the compiler if there is no constructor defined in the class. Parameterized Constructor: The parameterized constructor is the one which can initialize the instance variables with the given values. In other words, we can say that the constructors which can accept the arguments are called parameterized constructors.

There are two ways to do synchronization in java: Java automatic type conversion is done if the following conditions are met: Int can be assigned directly to long. Automatic type conversion takes place if int is assigned to long because long is larger datatype than int.

Widening Conversion comes under Automatic type conversion. We can handle exceptions in either of the two ways: Employee employee; In the above example employee object is not instantiate so it is pointed no where. We can have comments before the package statement. When we declare variables variables are created in stack.

So when the variable is out of scope those variables get garbage collected. When do we use synchronized blocks and advantages of using synchronized blocks? If very few lines of code requires synchronization then it is recommended to use synchronized blocks.

Viva questions pdf java and answers

The main advantage of synchronized blocks over synchronized methods is it reduces the waiting time of threads and improves performance of the system. What is the difference between access specifiers and access modifiers in java? But there is no such divison of access specifiers and access modifiers in java.

In Java we have access modifiers and non access modifiers. Access Modifiers: We can use only two access modifiers for class public and default. A class with public modifier can be visible 1 In the same class 2 In the same package subclass 3 In the same package nonsubclass 4 In the different package subclass 5 In the different package non subclass.

A class with default modifier can be accesed 1 In the same class 2 In the same package subclass 3 In the same package nonsubclass 4 In the different package subclass 5 In the different package non subclass. Sometimes we may come across a situation where we cannot provide implementation to all the methods in a class.

We want to leave the implementation to a class that extends it. In such case we declare a class as abstract. To make a class abstract we use key word abstract.

Viva answers java pdf and questions

Any class that contains one or more abstract methods is declared as abstract. We get the following error. For example if we take a vehicle class we cannot provide implementation to it because there may be two wheelers , four wheelers etc. At that moment we make vehicle class abstract. All the common features of vehicles are declared as abstract methods in vehicle class.

Any class which extends vehicle will provide its method implementation. The important features of abstract classes are: Though we cannot instantiate abstract classes we can create object references. Through superclass references we can point to subclass.

But when we cannot instantiate class there is no use in creating a constructor for abstract class. Abstract method is declared with keyword abstract and semicolon in place of method body. Java Exception Handling Interview questions. NumberFormatException 3 Invalid casting of class Class cast Exception 4 Trying to create object for interface or abstract class Instantiation Exception. In java exception is an object. Exceptions are created when an abnormal situations are arised in our program.

Exceptions can be created by JVM or by our application code. All Exception classes are defined in java. In otherwords we can say Exception as run time error. Error is the subclass of Throwable class in java.

When errors are caused by our program we call that as Exception, but some times exceptions are caused due to some environment issues such as running out of memory. Exceptions which cannot be recovered are called as errors in java.

Out of memory issues. It is recommended to handle exceptions with specific Exception instead of handling with Exception root class. If a method throws an exception and it is not handled immediately, then that exception is propagated or thrown to the caller of that method. This propogation continues till it finds an appropriate exception handler ,if it finds handler it would be handled otherwise program terminates Abruptly.

400+ TOP JAVA LAB VIVA Questions and Answers Pdf

We can create threads in java by any of the two ways: This is first and foremost way to create threads. By implementing runnable interface and implementing run method we can create new thread.

Method signature: If multiple threads tries to access a method where method can manipulate the state of object , in such scenario we can declare a method as synchronized. Finally block is used for cleaning up of resources such as closing connections, sockets etc. If there is exception thrown in try block finally block executes immediately after catch block. If an exception is thrown,finally block will be executed even if the no catch block handles the exception.

From Java 7, we can catch more than one exception with single catch block. This type of handling reduces the code duplication. When we catch more than one exception in single catch block , catch parameter is implicity final. We cannot assign any value to catch parameter.

Skip to content 1. Java Interview Questions And Answers 2. What is class in Java? What is a JVM? Explain method overloading? Does Java support multiple inheritance? Read Out: Common Interview Mistakes 7.

What is a transient variable? A transient variable is a variable that may not be serialized. Is null a keyword? No, the null is not a keyword. Java Interview Questions And Answers 9. These methods have been deprecated in JDK 1. What is the immediate superclass of the Applet class? The Panel class is the immediate superclass of the Applet class.