400+ TOP Digital Logic Design VIVA Questions and Answers

Digital Logic Design VIVA Questions :-

1) Explain about setup time and hold time, what will happen if there is setup time and hold tine violation, how to overcome this?

  • Set up time is the amount of time before the clock edge that the input signal needs to be stable to guarantee it is accepted properly on the clock edge.
  • Hold time is the amount of time after the clock edge that same input signal has to be held before changing it to make sure it is sensed properly at the clock edge.
  • Whenever there are setup and hold time violations in any flip-flop, it enters a state where its output is unpredictable: this state is known as metastable state (quasi stable state); at the end of metastable state, the flip-flop settles down to either ‘1’ or ‘0’. This whole process is known as metastability

2) What is skew, what are problems associated with it and how to minimize it?

  • In circuit design, clock skew is a phenomenon in synchronous circuits in which the clock signal (sent from the clock circuit) arrives at different components at different times.
  • This is typically due to two causes. The first is a material flaw, which causes a signal to travel faster or slower than expected. The second is distance: if the signal has to travel the entire length of a circuit, it will likely (depending on the circuit’s size) arrive at different parts of the circuit at different times. Clock skew can cause harm in two ways. Suppose that a logic path travels through combinational logic from a source flip-flop to a destination flip-flop. If the destination flip-flop receives the clock tick later than the source flip-flop, and if the logic path delay is short enough, then the data signal might arrive at the destination flip-flop before the clock tick, destroying there the previous data that should have been clocked through. This is called a hold violation because the previous data is not held long enough at the destination flip-flop to be properly clocked through. If the destination flip-flop receives the clock tick earlier than the source flip-flop, then the data signal has that much less time to reach the destination flip-flop before the next clock tick. If it fails to do so, a setup violation occurs, so-called because the new data was not set up and stable before the next clock tick arrived. A hold violation is more serious than a setup violation because it cannot be fixed by increasing the clock period.
  • Clock skew, if done right, can also benefit a circuit. It can be intentionally introduced to decrease the clock period at which the circuit will operate correctly, and/or to increase the setup or hold safety margins. The optimal set of clock delays is determined by a linear program, in which a setup and a hold constraint appears for each logic path. In this linear program, zero clock skew is merely a feasible point.
    Clock skew can be minimized by proper routing of clock signal (clock distribution tree) or putting variable delay buffer so that all clock inputs arrive at the same time

3) What is slack?

  • ‘Slack’ is the amount of time you have that is measured from when an event ‘actually happens’ and when it ‘must happen’.. The term ‘actually happens’ can also be taken as being a predicted time for when the event will ‘actually happen’.
  • When something ‘must happen’ can also be called a ‘deadline’ so another definition of slack would be the time from when something ‘actually happens’ (call this Tact) until the deadline (call this Tdead).
    Slack = Tdead – Tact.
  • Negative slack implies that the ‘actually happen’ time is later than the ‘deadline’ time…in other words it’s too late and a timing violation….you have a timing problem that needs some attention.

4) What is glitch? What causes it (explain with waveform)? How to overcome it?

The following figure shows a synchronous alternative to the gated clock using a data path. The flip-flop is clocked at every clock cycle and the data path is controlled by an enable. When the enable is Low, the multiplexer feeds the output of the register back on itself. When the enable is High, new data is fed to the flip-flop and the register changes its state

5) Given only two xor gates one must function as buffer and another as inverter?

  1. Tie one of xor gates input to 1 it will act as inverter.
  2. Tie one of xor gates input to 0 it will act as buffer.

6) What is difference between latch and flipflop?

The main difference between latch and FF is that latches are level sensitive while FF are edge sensitive. They both require the use of clock signal and are used in sequential logic. For a latch, the output tracks the input when the clock signal is high, so as long as the clock is logic 1, the output can change if the input also changes. FF on the other hand, will store the input only when there is a rising/falling edge of the clock.

7) Build a 4:1 mux using only 2:1 mux?

4:1 mux using only 2:1 mux

8.Difference between heap and stack?

The Stack is more or less responsible for keeping track of what’s executing in our code (or what’s been “called”). The Heap is more or less responsible for keeping track of our objects (our data, well… most of it – we’ll get to that later.).
Think of the Stack as a series of boxes stacked one on top of the next. We keep track of what’s going on in our application by stacking another box on top every time we call a method (called a Frame). We can only use what’s in the top box on the stack. When we’re done with the top box (the method is done executing) we throw it away and proceed to use the stuff in the previous box on the top of the stack. The Heap is similar except that its purpose is to hold information (not keep track of execution most of the time) so anything in our Heap can be accessed at any time. With the Heap, there are no constraints as to what can be accessed like in the stack. The Heap is like the heap of clean laundry on our bed that we have not taken the time to put away yet – we can grab what we need quickly. The Stack is like the stack of shoe boxes in the closet where we have to take off the top one to get to the one underneath it.

9) Difference between mealy and moore state machine?

A) Mealy and Moore models are the basic models of state machines. A state machine which uses only Entry Actions, so that its output depends on the state, is called a Moore model. A state machine which uses only Input Actions, so that the output depends on the state and also on inputs, is called a Mealy model. The models selected will influence a design but there are no general indications as to which model is better. Choice of a model depends on the application, execution means (for instance, hardware systems are usually best realized as Moore models) and personal preferences of a designer or programmer

B) Mealy machine has outputs that depend on the state and input (thus, the FSM has the output written on edges)
Moore machine has outputs that depend on state only (thus, the FSM has the output written in the state itself.

Adv and Disadv
In Mealy as the output variable is a function both input and state, changes of state of the state variables will be delayed with respect to changes of signal level in the input variables, there are possibilities of glitches appearing in the output variables. Moore overcomes glitches as output dependent on only states and not the input signal level.
All of the concepts can be applied to Moore-model state machines because any Moore state machine can be implemented as a Mealy state machine, although the converse is not true.
Moore machine: the outputs are properties of states themselves… which means that you get the output after the machine reaches a particular state, or to get some output your machine has to be taken to a state which provides you the output.The outputs are held until you go to some other state Mealy machine:
Mealy machines give you outputs instantly, that is immediately upon receiving input, but the output is not held after that clock cycle.

10) Difference between onehot and binary encoding?

Common classifications used to describe the state encoding of an FSM are Binary (or highly encoded) and One hot.
A binary-encoded FSM design only requires as many flip-flops as are needed to uniquely encode the number of states in the state machine. The actual number of flip-flops required is equal to the ceiling of the log-base-2 of the number of states in the FSM.
A onehot FSM design requires a flip-flop for each state in the design and only one flip-flop (the flip-flop representing the current or “hot” state) is set at a time in a one hot FSM design. For a state machine with 9- 16 states, a binary FSM only requires 4 flip-flops while a onehot FSM requires a flip-flop for each state in the design
FPGA vendors frequently recommend using a onehot state encoding style because flip-flops are plentiful in an FPGA and the combinational logic required to implement a onehot FSM design is typically smaller than most binary encoding styles. Since FPGA performance is typically related to the combinational logic size of the FPGA design, onehot FSMs typically run faster than a binary encoded FSM with larger combinational logic blocks

11) How to achieve 180 degree exact phase shift?

Never tell using inverter
a) dcm’s an inbuilt resource in most of fpga can be configured to get 180 degree phase shift.
b) Bufgds that is differential signaling buffers which are also inbuilt resource of most of FPGA can be used.

12) What is significance of ras and cas in SDRAM?

  • SDRAM receives its address command in two address words.
  • It uses a multiplex scheme to save input pins. The first address word is latched into the DRAM chip with the row address strobe (RAS).
  • Following the RAS command is the column address strobe (CAS) for latching the second address word.
  • Shortly after the RAS and CAS strobes, the stored data is valid for reading.

13) Tell some of applications of buffer?

a)They are used to introduce small delays
b)They are used to eliminate cross talk caused due to inter electrode capacitance due to close routing.
c)They are used to support high fanout,eg:bufg

14) Implement an AND gate using mux?

This is the basic question that many interviewers ask. for and gate, give one input as select line,incase if u r giving b as select line, connect one input to logic ‘0’ and other input to a.

15) What will happen if contents of register are shifter left, right?

  • It is well known that in left shift all bits will be shifted left and LSB will be appended with 0 and in right shift all bits will be shifted right and MSB will be appended with 0 this is a straightforward answer
  • What is expected is in a left shift value gets Multiplied by 2 eg:consider 0000_1110=14 a left shift will make it 0001_110=28, it the same fashion right shift will Divide the value by 2.

16)Given the following FIFO and rules, how deep does the FIFO need to be to prevent underflow or overflow?

RULES:
1) frequency(clk_A) = frequency(clk_B) / 4
2) period(en_B) = period(clk_A) * 100
3) duty_cycle(en_B) = 25%

Assume clk_B = 100MHz (10ns)
From (1), clk_A = 25MHz (40ns)
From (2), period(en_B) = 40ns * 400 = 4000ns, but we only output for
1000ns,due to (3), so 3000ns of the enable we are doing no output work. Therefore, FIFO size = 3000ns/40ns = 75 entries.

Digital Logic Design LAB VIVA Questions :

300+ TOP C Language LAB VIVA Questions with Answers Pdf

C Language LAB VIVA Questions :-

1. Who developed C language?

C language was developed by Dennis Ritchie in 1970 at Bell Laboratories.

2. Which type of language is C?

C is a high – level language and general purpose structured programming language.

3. What is a compiler?

Compile is a software program that transfer program developed in high level language intoexecutable object code

4. What is IDE?

The process of editing, compiling, running and debugging is managed by a single integratedapplication known as Integrated Development Environment (IDE)

5. What is a program?

A computer program is a collection of the instructions necessary to solve a specific problem.

6. What is an algorithm?

The approach or method that is used to solve the problem is known as algorithm.

7. What is structure of C program?

A C program contains Documentation section, Link section, Definition section, Globaldeclaration section, Main function and other user defined functions

8. What is a C token and types of C tokens?

The smallest individual units are known as C tokens. C has six types of tokens Keywords,Constants, Identifiers, Strings, Operators and Special symbols.

9.What is a Keyword?

Keywords are building blocks for program statements and have fixed meanings and thesemeanings cannot be changed.

10.How many Keywords (reserve words) are in C?

There are 32 Keywords in C language.

C Language LAB VIVA Questions
C Language LAB VIVA Questions

11.What is an Identifier?

Identifiers are user-defined names given to variables, functions and arrays.

12.What is a Constant and types of constants in C?

Constants are fixed values that do not change during the program execution. Types of constants are Numeric Constants (Integer and Real) and Character Constants (SingleCharacter, String Constants).

13.What are the Back Slash character constants or Escape sequence charactersavailable in C?

Back Slash character constant are \t, \n, \0

14.What is a variable?

Variables are user-defined names given to memory locations and are used to store values. Avariable may have different values at different times during program execution

15.What are the Data Types present in C?

Primary or Fundamental Data types (int, float, char), Derived Data types(arrays, pointers)and User-Defined data types(structures, unions, enum)

16.How to declare a variable?

The syntax for declaring variable isdata type variable_name-1, variable_name-2,….variable_name-n;

17.What is meant by initialization and how we initialize a variable?

While declaring a variable assigning value is known as initialization. Variable can beinitialized by using assignment operator (=).

18.What are integer variable, floating-point variable and character variable?

A variable which stores integer constants are called integer variable. A variable which storesreal values are called floating-point variable. A variable which stores character constants arecalled character variables.

19.How many types of operator or there in C?

C consist Arithmetic Operators (+, -, *, /,%), Relational Operators (<, <=, >, >=, !=), LogicalOperators (&&, ||, !), Assignment Operators (=, +=, -=, *=, /=), Increment and DecrementOperators (++, –), Conditional Operator(?:), Bitwise Operators(<<, >>, ~, &, |, ^) andSpecial Operators (. , ->, &, *, sizeof)

20. What is RAM ?

RAM – Random Access Memory is a temporary storage medium in a computer. RAM is a volatile memory i.e all data stored in RAM will be erased when the computer is switched off.

21. What do mean by network ?

Computer networking refers to connecting computers to share data, application software and hardware divices. Networks allow sharing of information among various computers and permit users to share files

22. List a few unconditional control statement in C.

  1. break statement
  2. continue statement
  3. goto statement
  4. exit() function

23. What is an array ?

An array is a collection of values of the same data type. Values in array are accessed using array name with subscripts in brackets[]. Synatax of array declaration is

data type array_ name[size];

24. What is Multidimensional Arrays

An array with more than one index value is called a multidimensional array. To declare a multidimensional array you can do follow syntax

data type array_ name[] [] []….;

25. Define string ?

An array of characters is known as a string.for example

char st[8]; this statement declares a string array with 80 characters .

26. Mention four important string handling functions in C languages .

There are four important string handling functions in C languages .

  • strlen();
  • trcpy();
  • strcat();
  • strcmp();

The header file #include is used when these functions are called in a C program.

27. Explain about the constants which help in debugging?

A #if directive test can be offered with #else and #else if directives. This allows conditional branching of the program to run sections of the code according to the result. Constants defined with a #define directive can be undefined with the #undef directive. The #ifdef directive has a companion directive #ifndef. These commands can be useful when debugging problem code to hide and unhide sections of the program.

28. Define and explain about ! Operator?

The logical operator ! NOT is a unary operator that is used before a single operand. It returns the inverse value of the given operand so if the variable “c” had a value of true then! C would return value of false. The not operator is very much useful in C programs because it can change the value of variables with successful iterations. This ensures that on each pass the value is changed.

29. What is operator precedence?

Operator precedence defines the order in which C evaluates expressions.

e.g. in the expression a=6+b*3, the order of precedence determines whether the addition or the multiplication is completed first. Operators on the same row have equal precedence.

30. Explain about the functions strcat() and strcmp()?

This function concatenates the source string at the end of the target string. Strcmp() function compares two strings to find out whether they are the same or different. The two strings are compared character by character until there is a mismatch or end of one of the strings is reached, whichever occurs first. If in case two strings are identical, a value of zero is returned. If there is no matches between two strings then a difference of the two non matching values are returned according to ASCII values.

31. Define function

A function is a module or block of program code which deals with a particular task. Each function has a name or identifier by which is used to refer to it in a program. A function can accept a number of parameters or values which pass information from outside, and consists of a number of statements and declarations, enclosed by curly braces { }, which make up the doing part of the object

32. Differentiate built-in functions and user – defined functions.

Built – in functions are used to perform standard operations such as finding the square root of a number, absolute value and so on. These are available along with the C compiler and are included in a program using the header files math.h, s tring.h and so on.

User defined functions are written by the user or programmer to compute a value or perform a task. It contains a statement block which is executed during the runtime whenever it is called by the main program.

33. Distinguish between actual and formal arguments.

Actual arguments are variables whose values are supplied to the function in any function call. Formal arguments are variables used to receive the values of actual arguments from the calling program.

34. Explain the concept and use of type void.

A function which does not return a value directly to the calling program is referred as a void function. The void functions are commonly used to perform a task and they can return many values through global variable declaration.

35. What is recursion ?

A function calling itself again and again to compute a value is referref to as recursive function or recursion. Recursion is useful for branching processes and is effective where terms are generated successively to compute a value.

c programming viva questions and answers pdf ::

400+ TOP JAVA LAB VIVA Questions and Answers Pdf

JAVA LAB VIVA Questions with Answers :-

1. What is Java?
Java is a high-level programming language originally developed by Sun Microsystems and released in 1995. Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX.

2. What is the most important feature of Java?
Java is a platform independent language.

3. What do you mean by platform independence?
Platform independence means that we can write and compile the java code in one platform (eg Windows) and can execute the class in any other supported platform eg (Linux,Solaris,etc).

4. What are the supported platforms by Java Programming Language?
Java runs on a variety of platforms, such as Windows, Mac OS, and the various versions of UNIX/Linux like HP-Unix, Sun Solaris, Redhat Linux, Ubuntu, CentOS, etc.

5. What is the difference between a JDK and a JVM?
JDK is Java Development Kit which is for development purpose and it includes execution environment also. But JVM is purely a run time environment and hence you will not be able to compile your source files using a JVM.

      Click Here   —————->JAVA Interview Questions<———————–

6. What are the access modifiers in Java?
There are 3 access modifiers. Public, protected and private, and the default one if no identifier is specified is called friendly, but programmer cannot specify the friendly identifier explicitly.

7. What is are packages?
A package is a collection of related classes and interfaces providing access protection and namespace management.

8. What is meant by Inheritance and what are its advantages?
Inheritance is the process of inheriting all the features from a class. The advantages of inheritance are reusability of code and accessibility of variables and methods of the super class by sub classes.

9. What is the difference between superclass and subclass?
A super class is a class that is inherited whereas sub class is a class that does the inheriting.

10. What is an abstract class?
An abstract class is a class designed with implementation gaps for sub classes to fill in and is deliberately incomplete.

JAVA VIVA Questions

11. What are the states associated in the thread?
Thread contains ready, running, waiting and dead states.

12. What is synchronization?
Synchronization is the mechanism that ensures that only one thread is accessed the resources at a time.

13. What is deadlock?
When two threads are waiting each other and can’t precede the program is said to be deadlock.

14. What is an applet?
Applet is a dynamic and interactive program that runs inside a web page displayed by a java capable browser

15. What is the lifecycle of an applet?
init() method – Can be called when an applet is first loaded
start() method – Can be called each time an applet is started.
paint() method – Can be called when the applet is minimized or maximized.
stop() method – Can be used when the browser moves off the applet’s page.
destroy() method – Can be called when the browser is finished with the applet.

16. How do you set security in applets?
using setSecurity Manager() method

17. What is a layout manager and what are different types of layout managers available in java AWT?
A layout manager is an object that is used to organize components in a container. The different layouts are available are FlowLayout, BorderLayout, CardLayout, GridLayout and GridBagLayout

18. What is JDBC?
JDBC is a set of Java API for executing SQL statements. This API consists of a set of classes and interfaces to enable programs to write pure Java Database applications.

19. What are drivers available?
a) JDBC-ODBC Bridge driver b) Native API Partly-Java driver
c) JDBC-Net Pure Java driver d) Native-Protocol Pure Java driver

20. What is stored procedure?
Stored procedure is a group of SQL statements that forms a logical unit and performs a particular task. Stored Procedures are used to encapsulate a set of operations or queries to execute on database. Stored procedures can be compiled and executed with different parameters and results and may have any combination of input/output parameters.

21. What is the Java API?
The Java API is a large collection of ready-made software components that provide many useful capabilities, such as graphical user interface (GUI) widgets.

22. Why there are no global variables in Java?
Global variables are globally accessible. Java does not support globally accessible variables due to following reasons:

  1. The global variables breaks the referential transparency
  2. Global variables creates collisions in namespace.

23. What are Encapsulation, Inheritance and Polymorphism?
Encapsulation is the mechanism that binds together code and data it manipulates and keeps both safe from outside interference and misuse. Inheritance is the process by which one object acquires the properties of another object. Polymorphism is the feature that allows one interface to be used for general class actions.

24. What is the use of bin and lib in JDK?
Bin contains all tools such as javac, appletviewer, awt tool, etc., whereas lib contains API and all packages.

25. What is method overloading and method overriding?
Method overloading: When a method in a class having the same method name with different arguments is said to be method overloading. Method overriding : When a method in a class having the same method name with same arguments is said to be method overriding.

26. What is the difference between this() and super()?
this() can be used to invoke a constructor of the same class whereas super() can be used to invoke a super class constructor.

27. What is Domain Naming Service(DNS)?
It is very difficult to remember a set of numbers(IP address) to connect to the Internet. The Domain Naming Service(DNS) is used to overcome this problem. It maps one particular IP address to a string of characters. For example, www. mascom. com implies com is the domain name reserved for US commercial sites, moscom is the name of the company and www is the name of the specific computer, which is mascom’s server.

28. What is URL?
URL stands for Uniform Resource Locator and it points to resource files on the Internet. URL has four components: http://www. address. com:80/index.html, where http – protocol name, address – IP address or host name, 80 – port number and index.html – file path.

29. What is RMI and steps involved in developing an RMI object?
Remote Method Invocation (RMI) allows java object that executes on one machine and to invoke the method of a Java object to execute on another machine. The steps involved in developing an RMI object are:

  • Define the interfaces
  • Implementing these interfaces
  • Compile the interfaces and their implementations with the java compiler
  • Compile the server implementation with RMI compiler
  • Run the RMI registry
  • Run the application.

30. What is RMI architecture?
RMI architecture consists of four layers and each layer performs specific functions: a) Application layer – contains the actual object definition. b) Proxy layer – consists of stub and skeleton. c) Remote Reference layer – gets the stream of bytes from the transport layer and sends it to the proxy layer. d) Transportation layer – responsible for handling the actual machine-to-machine communication.

31. Why Java?
The programs that we are writing are very similar to their counterparts in several other languages, so our choice of language is not crucial. We use Java because it is widely available, embraces a full set of modern abstractions, and has a variety of automatic checks for mistakes in programs, so it is suitable for learning to program. There is no
perfect language, and you certainly will be programming in other languages in the future.

32. Do I really have to type in the programs in the book to try them out?
Everyone should type in HelloWorld.java, but you can find all of the code in this book (and much more) on this booksite.

33. What are Java’s rules regarding tabs, spaces and newline characters?
There are not many. Java compilers treat them all to be equivalent. For example, we could also write HelloWorld as follows:

public class HelloWorld { public static void main (
String [] args) { System.out.println(“Hello World”) ; } }

But we do normally adhere to spacing and indenting conventions when we write Java programs, just as we always indent paragraphs and lines consistently when we write prose or poetry.

34. What are the rules regarding quotation marks?
Material inside quotation marks is an exception to the rule of the previous question:
things within quotes are taken literally so that you can precisely specify what gets printed. If you put any number of successive spaces within the quotes, you get that number of spaces in the output. If you accidentally omit a quotation mark, the compiler may get very confused, because it needs that mark to distinguish between characters in the string and other parts of the program. To print a quotation mark, a newline, or a tab, use \”, \n, or \t, respectively, within the quotation marks.

35. What is the meaning of the words public, static and void?
These keywords specify certain properties of main() that you will learn about later in the book. For the moment, we just include these keywords in the code (because they are required) but do not refer to them in the text.

36. What happens when you omit a brace or misspell one of the words, like public or
static or main?
It depends upon precisely what you do. Such errors are called syntax errors. Try it out and see.

37. Can a program use more than one command-line argument?
Yes, you can put several, though we normally use only a few. You refer to the second one as args[1], the third one as args[2], and so forth. Note that we start counting from 0 in Java.

38. What Java systems libraries and methods are available for me to use?
There are thousands of them, but we introduce them to you in a deliberate fashion in this book to avoid overwhelming you with choices.

39. How should I format my code? How should I comment my code?
Programmers use coding guidelines to make programs easier to read, understand, and maintain. As you gain experience, you will develop a coding style, just as you develop style when writing prose. Appendix B provides some guidelines for formatting and commenting your code. We recommend returning to this appendix after you’ve written a few programs.

40. What exactly is a .class file?
It’s a binary file (sequence of 0s and 1s). If you are using Unix or OS X, you can examine its contents by typing od -x HelloWorld.class at the command prompt. This displays the results in hexadecimal (base 16). In deference to Java’s name, the first word of every .class file is cafe.

41. How do I get the | symbol on my keyboard?
It’s there. Often it’s above the \ symbol.

42. Java prints out a ton of digits when I System.out.println() a double. How can I format it so it displays only 3 digits after the decimal place?
Use the method System.out.printf() described in Section 1.5.

43. Why does the integer quotient -0/3 yield 0, but the double quotient -0.0/3.0 yields – 0.0?
Java represent integers using something called two’s complement notation, and there is only one representation of 0. (You’ll learn about this in Section 5.1.) Java represents doubles using IEEE specifications, and there are two distinct representations of the number zero, 0 and -0. (You’ll learn about this in Section 9.1.)

44. What happens when I use / and % with a negative numerator?
Try it and see. -47 / 5 = -9 and -47 % 5 = -2. The quotient is always rounded toward zero. To ensure the Euclidean property b * (a / b) + (a % b) = a, the result of the remainder operator can be negative. This convention was inherited from ancestral

languages like FORTRAN and C. Some languages (but not Java) include both remainder and modulo operators because it is often convenient to have a version that returns only nonnegative integers.

45. Can I use % with real numbers?
Yes. If angle is nonnegative, then angle % (2 * Math.PI) converts the angle to be
between 0 and 2 π.

46. How do I print a “?
Since ” is a special character when dealing with strings, you must escape the convention rules by using \”. For example, System.out.println(“The pig said \”Oink Oink\” afterwards”);.

47. OK, so then how do I print a \?
Use “\\”.

48. Why do I need to declare the type of a variable in Java?
By specifying the type, the compiler can alert you of potential errors, say if you try to multiply an integer with a string. For the same reason, when doing physics calculations, it is always a good idea to keep track of the units and make sure they “type check.” For small programs, this may not seem important; for large programs it is crucial. The Ariane 5 rocket exploded 40 seconds after takeoff because of a bug in its software that incorrectly converted a 64 bit real number into a 16 bit integer.

49. Why is the type for real numbers called double?
Historically, the type for floating point numbers was float, but they had limited
accuracy. The type double was introduced as a floating point type with twice as much
accuracy.

50. Is it correct to say that using parentheses can only change
Almost, with one surprising exception. The literal value 2147483648 (2^31) is only permitted as an operand of the unary minus operator, i.e., -2147483648. Enclosing it in parentheses, i.e., -(2147483648), leads to a compile-time error.

51.What is JVM?
The Java interpreter along with the run time environment required to run the Java application in called as Java virtual machine(JVM)

52. What is the base class of all classes?
java.lang.Object

53. Explain Set Interface?
It is a collection of element which cannot contain duplicate elements. The Set interface contains only methods inherited from Collection and adds the restriction that duplicate elements are prohibited.

54. Explain TreeSet?
It is a Set implemented when we want elements in a sorted order.

55. What is Comparable Interface?
It is used to sort collections and arrays of objects using the collections.sort() and java.utils. The objects of the class implementing the Comparable interface can be ordered.

56. Difference between throw and throws?
It includes: Throw is used to trigger an exception where as throws is used in declaration of exception. Without throws, Checked exception cannot be handled where as checked exception can be propagated with throws.

57. Explain the following line used under Java Program: public static void main (String args[ ])
The following shows the explanation individually:

public: it is the access specifier.

static: it allows main() to be called without instantiating a particular instance of a class.

void: it affirns the compiler that no value is returned by main().

main(): this method is called at the beginning of a Java program.

String args[ ]: args parameter is an instance array of class String

58. Define JRE i.e. Java Runtime Environment?
Java Runtime Environment is an implementation of the Java Virtual Machine which executes Java programs. It provides the minimum requirements for executing a Java application;

59. What is JAR file?
JAR files is Java Archive fles and it aggregates many files into one. It holds Java classes in a library. JAR files are built on ZIP file format and have .jar file extension.

60. What is a WAR file?
This is Web Archive File and used to store XML, java classes, and JavaServer pages. which is used to distribute a collection of JavaServer Pages, Java Servlets, Java classes, XML files, static Web pages etc.

61. Define JIT compiler?
It improves the runtime performance of computer programs based on bytecode.

62. What is the difference between object oriented programming language and object based programming language?
Object based programming languages follow all the features of OOPs except Inheritance. JavaScript is an example of object based programming languages

63. What is the purpose of default constructor?
The java compiler creates a default constructor only if there is no constructor in the class.

64. Can a constructor be made final?
No, this is not possible.

65. What is static block?
It is used to initialize the static data member, It is excuted before main method at the time of classloading.

66. Define composition?
Holding the reference of the other class within some other class is known as composition.

67. What is function overloading?
If a class has multiple functions by same name but different parameters, it is known as Method Overloading.

68. What is function overriding?
If a subclass provides a specific implementation of a method that is already provided by its parent class, it is known as Method Overriding.

69. Difference between Overloading and Overriding?
Method overloading increases the readability of the program. Method overriding provides the specific implementation of the method that is already provided by its super class parameter must be different in case of overloading, parameter must be same in case of overriding.

70. What is final class?
Final classes are created so the methods implemented by that class cannot be overridden. It can’t be inherited.

71. What is NullPointerException?
A NullPointerException is thrown when calling the instance method of a null object, accessing or modifying the field of a null object etc.

72. What are the ways in which a thread can enter the waiting state?
A thread can enter the waiting state by invoking its sleep() method, by blocking on IO, by unsuccessfully attempting to acquire an object’s lock, or by invoking an object’s wait() method. It can also enter the waiting state by invoking its (deprecated) suspend() method.

73. How does multi-threading take place on a computer with a single CPU?
The operating system’s task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.

74. What invokes a thread’s run() method?
After a thread is started, via its start() method of the Thread class, the JVM invokes the thread’s run() method when the thread is initially executed.

75. Does it matter in what order catch statements for FileNotFoundException and IOException are written?
Yes, it does. The FileNoFoundException is inherited from the IOException. Exception’s subclasses have to be caught first.

76. What is the difference between yielding and sleeping?
When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep() method, it returns to the waiting state.

77. Why Vector class is used?
The Vector class provides the capability to implement a growable array of objects. Vector proves to be very useful if you don’t know the size of the array in advance, or you just need one that can change sizes over the lifetime of a program.

78. How many bits are used to represent Unicode, ASCII, UTF-16, and UTF-8 characters?
Unicode requires 16 bits and ASCII require 7 bits. Although the ASCII character set uses only 7 bits, it is usually represented as 8 bits. UTF-8 represents characters using 8, 16, and 18 bit patterns. UTF-16 uses 16-bit and larger bit patterns.

79. What are Wrapper classes?
These are classes that allow primitive types to be accessed as objects. Example: Integer, Character, Double, Boolean etc.

80. What is the difference between a Window and a Frame?
The Frame class extends Window to define a main application window that can have a menu bar.

81. Which package has light weight components?
javax.Swing package. All components in Swing, except JApplet, JDialog, JFrame and JWindow are lightweight components.

82. What is the difference between the paint() and repaint() methods?
The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.

83. What is the purpose of File class?
It is used to create objects that provide access to the files and directories of a local file system.

84. What is the difference between the Reader/Writer class hierarchy and the InputStream/OutputStream class hierarchy?
The Reader/Writer class hierarchy is character-oriented, and the InputStream/OutputStream class hierarchy is byte-oriented.

85. Which class should you use to obtain design information about an object?
The Class class is used to obtain information about an object’s design and java.lang.Class class instance represent classes, interfaces in a running Java application.

86. What is the difference between static and non-static variables?
A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.

87. What is Serialization and deserialization?
Serialization is the process of writing the state of an object to a byte stream. Deserialization is the process of restoring these objects.

88. Can you write a Java class that could be used both as an applet as well as an application?
Yes, just add a main() method to the applet.

89. What is the difference between Swing and AWT components?
AWT components are heavy-weight, whereas Swing components are lightweight. Heavy weight components depend on the local windowing toolkit. For example, java.awt.Button is a heavy weight component, when it is running on the Java platform for Unix platform, it maps to a real Motif button.

90. What’s the difference between constructors and other methods?
Constructors must have the same name as the class and can not return a value. They are only called once while regular methods could be called many times.

91. Is there any limitation of using Inheritance?
Yes, since inheritance inherits everything from the super class and interface, it may make the subclass too clustering and sometimes error-prone when dynamic overriding or dynamic overloading in some situation.

92. What’s the difference between the methods sleep() and wait()?
The code sleep(2000); puts thread aside for exactly two seconds. The code wait(2000), causes a wait of up to two second. A thread could stop waiting earlier if it receives the notify() or notifyAll() call. The method wait() is defined in the class Object and the method sleep() is defined in the class Thread.

93. When ArithmeticException is thrown?
The ArithmeticException is thrown when integer is divided by zero or taking the remainder of a number by zero. It is never thrown in floating-point operations.

94. What is the Collections API?
The Collections API is a set of classes and interfaces that support operations on collections of objects.

95. Does garbage collection guarantee that a program will not run out of memory?
Garbage collection does not guarantee that a program will not run out of memory. It is possible for programs to use up memory resources faster than they are garbage collected. It is also possible for programs to create objects that are not subject to garbage collection.

96. What is the difference between a break statement and a continue statement?
A break statement results in the termination of the statement to which it applies (switch, for, do, or while). A continue statement is used to end the current loop iteration and return control to the loop statement.

97. If a variable is declared as private, where may the variable be accessed?
A private variable may only be accessed within the class in which it is declared.

98. What is JVM ? Why is Java called the “Platform Independent Programming Language” ?
A Java virtual machine (JVM) is a process virtual machine that can execute Java bytecode. Each Java source file is compiled into a bytecode file, which is executed by the JVM. Java was designed to allow application programs to be built that could be run on any platform, without having to be rewritten or recompiled by the programmer for each separate platform. A Java virtual machine makes this possible, because it is aware of the specific instruction lengths and other particularities of the underlying hardware platform.

99. What is the Difference between JDK and JRE ?
The Java Runtime Environment (JRE) is basically the Java Virtual Machine (JVM) where your Java programs are being executed. It also includes browser plugins for applet execution. The Java Development Kit (JDK) is the full featured Software Development Kit for Java, including the JRE, the compilers and tools (like JavaDoc, and Java Debugger), in order for a user to develop, compile and execute Java applications.

100. Explain the available thread states in a high-level.
During its execution, a thread can reside in one of the following states:

Runnable: A thread becomes ready to run, but does not necessarily start running immediately.

Running: The processor is actively executing the thread code.

Waiting: A thread is in a blocked state waiting for some external processing to finish.

Sleeping: The thread is forced to sleep.

Blocked on I/O: Waiting for an I/O operation to complete. Blocked on Synchronization: Waiting to acquire a lock.

Dead: The thread has finished its execution.

101. What is the primary benefit of Encapsulation?
The main benefit of encapsulation is the ability to modify our implemented code without breaking the code of others who use our code. With this Encapsulation gives maintainability, flexibility and extensibility to our code.

102. What is an Interface?
An interface is a collection of abstract methods. A class implements an interface, thereby inheriting the abstract methods of the interface.

103. Give some features of Interface?
It includes: Interface cannot be instantiated An interface does not contain any constructors. All of the methods in an interface are abstract.

104. Define Packages in Java?
A Package can be defined as a grouping of related types(classes, interfaces, enumerations and annotations ) providing access protection and name space management.

105. Why Packages are used?
Packages are used in Java in-order to prevent naming conflicts, to control access, to make searching/locating and usage of classes, interfaces, enumerations and annotations, etc., easier.

106. What do you mean by Multithreaded program?
A multithreaded program contains two or more parts that can run concurrently. Each part of such a program is called a thread, and each thread defines a separate path of execution.

107. What are the two ways in which Thread can be created?
Thread can be created by: implementing Runnable interface, extending the Thread class.

108. What is an applet?
An applet is a Java program that runs in a Web browser. An applet can be a fully functional Java application because it has the entire Java API at its disposal.

109. An applet extend which class?
An applet extends java.applet.Applet class.

110. Explain garbage collection in Java?
It uses garbage collection to free the memory. By cleaning those objects that is no longer reference by any of the program.