Viva Questions for Java Lab
Download Viva Questions for Java Lab...
Viva Questions for Java Lab by Basics What is Java? Java is an object oriented programming language Is Java invented for Internet? No, it was developed for programming towards tiny devices What is byte code? It is machine understandable code and targeted for JVM (Java Virtual Machine). It is class file. What is JVM? Java Virtual Machine which accepts java byte code and produces result What are java buzzwords? Java buzzwords explain the important features of java. They are Simple, Secured, Portable, architecture neutral, high performance, dynamic, robust, interpreted etc. Is byte code is similar to .obj file in C? Yes, both are machine understandable codes No, .obj file directly understood by machine, byte code requires JVM What is new feature in control statements comparing with C/C++? Labeled break and labeled continue are new What are new features in basic features comparing with C/C++? Data types: All data types on all machines have fixed size; Constants: final is used to declare constant Boolean Type: boolean is new data type in Java which can store true/false There are no structures/unions/pointers Is String data type? No, Strings are classes in Java (Arrays are classes) What are length and length( ) in Java? Both gives number of char/elements, length is variable defined in Array class, length( ) is method defined in String class Object-Orientation Section
What is class? Class is blue print for objects; Class is collection of objects; Class gives the general structure for objects. What is object? Object is an instance of class. Object is real world entity which has state, identity and behavior. What is encapsulation? Encapsulation is packing of data with their methods What is abstraction? Abstraction is the process of identification of essential features of objects What is data hiding? Implementation details of methods are hidden from the user What is hierarchy? Ordering of classes (or inheritance) What is inheritance? Extending an existing class is called inheritance. Extracting the features of super class Why inheritance is important? Reusability is achieved through inheritance Which types of inheritances are available in Java? Simple, Hierarchical and Multilevel Can we achieve multiple inheritances in Java? With the help of interfaces we can achieve What is interface? Interface is collection of final variables and abstract methods (We need not give final and abstract keywords and By default they are public methods) What is the difference between class and interface? Class contains implemented methods, but interface contains non-implemented methods What is polymorphism? Multiple (poly) forms (morphs) Same instance can respond different manners is called polymorphism Can we achieve run time polymorphism in Java? Yes, also called as dynamic polymorphism. Possible by dynamic method dispatch
What is dynamic method dispatch? When you assign object of sub class for the super class instance, similar methods of super class are hidden What is overloading? Same method name can be used with different type and number of arguments (in same class) What is overriding? Same method name, similar arguments and same number of arguments can be defined in super class and sub class. Sub class methods override the super class methods. What is the difference between overloading and overriding? Overloading related to same class and overriding related sub-super class Compile time polymorphism achieved through overloading, run time polymorphism achieved through overriding Keywords section What is keyword? Java reserved word which should is not used as variable/class-name (e.g.: break, for, if, while etc) What is final keyword? Used before variables for declaring constants Used before methods for preventing from overriding Used before class-name for preventing from inheritance What is static keyword? Used before variable for defining shared variables Used before method for defining class-level methods, these methods can be called without creating objects (e.g.: parseInt method of Integer class) What is abstract keyword? Used for creating abstract class, class which doesn't have any instance What is this keyword? To call current class variables and current class methods we can use this key word What is this( )? Used for calling another constructor of current class What is super keyword? To call super class variables and super class methods we can use super key word
What is super( )? Used for calling of super class constructor and it should be first executable statement in sub class constructor Packages and Exception handling section: What is package? Package is collection of classes and interfaces How to define package? By using package keyword before the definition of class What is CLASSPATH? It is an environment variable which is used for defining the location of class files What is jar? Jar stands for Java archive files, compressed set of class files and can be used in CLASSPATH What is the meaning of import java.awt.*;? Import all the classes and interfaces in the java.awt.package. This doesn't imports other packages defined in java.awt. package. Is it necessary to give import java.awt.event.*;, when already import java.awt.* given? Yes, import java.awt.* doesn't imports event package defined in java.awt. package. What is exception? Abnormal termination of program is called exception What is exception handler? A method which controls abnormal termination of program What are the keywords used for exception handling? try, catch, throw, throws and finally What is the difference between throw and throws keywords? throw keyword is used for invoking an exception (For raising) throws keyword lists exception names which can be ignored from the method execution What is the difference between final and finally? final is used for defining constants finally is used for executing code after completion of exception handler What is catch( ) block?
Exception handler that controls abnormal termination of program Can we have multiple catch( ) blocks? Yes, but first sub class exceptions should be handled What happen is we not handle sub class exception first? Generates compile time error saying that unreachable code is defined in the program Multithreading Section What is thread? Thread is a part of process, also called as light weight process What is multithreading? Simultaneous execution of threads is called multithreading What is a process? Program under execution is called process How to create thread? By creating instance of Thread class or implementing Runnable interface Can you name any methods of Thread class? currentThread( ), setName( ), getName( ), setPriority( ), getPriority( ), join( ), isAlive( ) What is join( ) method of Thread? Combines two or more threads running process and wait till their execution is completed What are the states in Thread Life Cycle? Ready, running, block, wait, dead Applets, AWT Section What is an applet? Applet is a java program which runs via java-enabled browser Is graphics possible only in applets? No, stand alone program frames can also display graphics What is the relation between java and Internet? With the help of java applets, we can write programming for Internet Which package is required to write GUI (Graphical User Interface) programs? Java.awt
Which package is required to write Applets? Java.applet What is an event? A kind of action What is event handling? A procedure which gives functionality for the events How to implement event handling? By using interfaces like ActionListener, MouseListener What is the method available in ActionListener Interface? public void action performed(AcitonEvent e) How to pass parameters to Applets? By using PARAM tag. C++ Questions from OOPS Basics 3/7/08 Define object oriented programming? 3/7/08List some features of OOP? 4/7/08 Give some advantages of OOP’s? 4/7/08 What are the object oriented languages used? 4/7/08Give some applications of OOPs? 3/7/08 What are the basic concepts of OOPs? 3/7/08Define data encapsulation? 3/7/08What is inheriblackce? Questions from C++ Basics 4/7/08 Give the structure of a C++ program? 4/7/08 What is a comment? 4/7/08List some tokens? 4/7/08 Define keywords? 4/7/08 What is an expression? 4/7/08 Define arrays? 3/7/08 What is an enumerated data type? 4/7/08 What are the two ways to create symbolic consblackt? 4/7/08What are the two forms of if statement? 4/7/08 Write a program to display the following using single cout statement? Name = XXX Age = 23 4/7/08What are the new operators used in C++? 5/7/08What is the purpose for the return statement?
5/7/08 What is a call by reference? 5/7/08Define call by value? 5/7/08 What are consblackt arguments? 5/7/08Define default argument? Questions from C++ Classes 3/7/08Define objects? 3/7/08Define class? 4/7/08 Define structures and classes? 5/7/08What the two specifications of a class? 5/7/08 What is a class? 5/7/08How is a member function of a class defined? 5/7/08 What are the characteristics of a member function? 5/7/08 Define nesting of member function? 6/7/08Define constructor? 6/7/08 Define destructor? 6/7/08List the difference between constructor and destructor? 6/7/08 Define dynamic constructor? 6/7/08 What are the special characteristics of constructor? 6/7/08What is parameterized constructor? 6/7/08What are the two ways in which a parameterized constructor can be called? 6/7/08What are the kinds of constructors that we call? 6/7/08 What is the advantage of using dynamic initialization? 6/7/08 What are copy constructors? Explain with example? 5/7/08 How an object as function argument can be done? 7/7/08 What is nesting of classes? Questions from C++ Functions-Inline Functions 5/7/08Define macro? 5/7/08 What do you inline function? 5/7/08 What are the situations that inline functions may not work? 5/7/08Explain function prototype? Questions from C++ static and this 5/7/08What are the characteristic of a static data member? 5/7/08 Give the properties of the static member functions? 7/7/08 What is this pointer? Questions from C++ Functions-friend functions 5/7/08 Define friend function? 5/7/08 What are the characteristics of the friend function? Questions from C++ dynamic memory 4/7/08Define pointers? 4/7/08Define dynamic binding? 6/7/08 What is the advantage of using dynamic initialization?
Questions from C++ Overloading 5/7/08 Explain function overloading? 3/7/08 Define operator overloading? 6/7/08 Give the operator in C++ which cannot be overloaded? 6/7/08 How can we overload an operator? 7/7/08Give any four rules for operator overloading? 7/7/08 What are the steps that involves in the process of overloading? 7/7/08 What are the restriction and limitations overloading operators? 7/7/08Give a function overload a unary minus operator using friend function? 7/7/08 Define unary and binary operator overloading? 7/7/08 Explain overloading of new and delete operators? 7/7/08 Define type conversion? 7/7/08 What are the three types of conversion takes place? 7/7/08 When and how the conversion function exists? 7/7/08Give the syntax for overloading with friend functions? Questions from C++ Inheriblackce 7/7/08Define inheriblackce? 7/7/08 What are the types in inheriblackce? 7/7/08Explain single inheriblackce? 7/7/08What is multiple inheriblackce? 7/7/08 Define hierarchical inheriblackce? 7/7/08 What is hybrid inheriblackce? 7/7/08 What is multilevel inheriblackce? Questions from C++ Base Class Access Control 5/7/08Define private base classes? 7/7/08 What is virtual base class? 7/7/08What is abstract class? Questions from C++ Run-time Polymorphism 7/7/08What is polymorphism? 7/7/08 What are the types of polymorphism? 7/7/08 What is compile time polymorphism? 7/7/08 What the types in compile time polymorphism? 7/7/08 What is virtual function? 9/7/08 What are the rules for virtual function? 9/7/08 What is pure virutal function? Questions from C++ Streams 9/7/08 What are the file stream classes in C++? 9/7/08 What are the file manipulation function in C++? 9/7/08 What are the file open modes? 9/7/08 What are the error handling function in C+ +?
JAVA Define abstract class and method? Define Abstractions? Define Class and objects Define class Variable? Define Dead Lock? Define Interface? Define method overloading? Define method overriding? Define multithreaded programming? How multithreading is implemented in java? Define Package? Define polymorphism? Define sub class? Define Synchronization. How it is implemented in java? Define Synchronization? Define Thread? Distinguish between paint and update method? Distinguish between public, private and protected? Distinguish between Throw and Throws? Explain the structure of a typical java program? How a Package is created in java? How an Exception is handled in java? How is an interface is used in java? How parameters are passed to an Applet? How Reader and Writer Classes are used in java? How Threads are created in Java? How we can get the size of an array? List out some UI components available in AWT? List out the features of Java? List out the various types of inheritance? What are known as three pillars of object-oriented programming? What are methods available in the Applet class? What are the decision-making statements available in java? What are the difference between the abstract class and interface? What are the various applications of Java What are the various states of a thread? What do you mean by API? What do you mean by casting? What do you mean by core packages? What do you mean by garbage collection? Why do we need finalize() method? What do you mean by Thread Scheduling? What is a destructor and how it is implemented in java? What is an access specifier? What is an Applet? What is an Exception? What is an instance variable of a class? What is AWT? What is branching? What is byte code? What is conditional and unconditional branching? What is encapsulation? What is its role in object-oriented programming?
What is filtered Stream? What is Garbage collection? What is Hot Java ? What is inheritance? What is multithreaded programming? What is static method? What is super class? What is the difference between call-by-value and call–by- reference? What is the scope and lifetime of variables in java? What is the use of ‘this’ key word? What is the use of break statement? What is the use of Buffered Streams? What is the use of continue statement? What is the use of Data input and ouput streams? What is the use of Finally block? What is the use of SequenceInputStream? What is the use of super keyword? What is the use of switch statement? What is the use of the ?: operator? What is the use of transient keyword? What is Thread Pool? What is thread priority? What is Unicode? What is Wrapper class? What the use of InputStream and OutputStream classes? Why do java is called platform independent? Why two classes are used to handle String in java? Write an example java program to illustrate method overloading? Write down the control flow statement available in java? Write down the features of java? Write short note on isAlive() and join()? Write short notes on final key word? Write some methods, which are used to add UI components in Applet? Write the attributes of the Applet tag? Write the Html code to load an Applet in the browser?