Showing posts with label core java interview questions. Show all posts
Showing posts with label core java interview questions. Show all posts

Friday, 22 December 2017

How to use operation amplifiers in electronic circuits. step by step, easy and top guide to learn quickly




Operational Amplifier Basics

As well as resistors and capacitors, Operational Amplifiers, or Op-amps as they are more commonly called, are one of the basic building blocks of Analogue Electronic Circuits.Operational amplifiers are linear devices that have all the properties required for nearly ideal DC amplification and are therefore used extensively in signal conditioning, filtering or to perform mathematical operations such as add, subtract, integration and differentiation.
An Operational Amplifier, or op-amp for short, is fundamentally a voltage amplifying device designed to be used with external feedback components such as resistors and capacitors between its output and input terminals. These feedback components determine the resulting function or “operation” of the amplifier and by virtue of the different feedback configurations whether resistive, capacitive or both, the amplifier can perform a variety of different operations, giving rise to its name of “Operational Amplifier”.
An Operational Amplifier is basically a three-terminal device which consists of two high impedance inputs, one called the Inverting Input, marked with a negative or “minus” sign, ( - ) and the other one called the Non-inverting Input, marked with a positive or “plus” sign ( + ).
The third terminal represents the Operational Amplifiers output port which can both sink and source either a voltage or a current. In a linear operational amplifier, the output signal is the amplification factor, known as the amplifiers gain ( A ) multiplied by the value of the input signal and depending on the nature of these input and output signals, there can be four different classifications of operational amplifier gain.
  • Voltage  – Voltage “in” and Voltage “out”
  • Current  – Current “in” and Current “out”
  • Transconductance  – Voltage “in” and Current “out”
  • Transresistance  – Current “in” and Voltage “out”
Since most of the circuits dealing with operational amplifiers are voltage amplifiers, we will limit the tutorials in this section to voltage amplifiers only, (Vin and Vout).
The output voltage signal from an Operational Amplifier is the difference between the signals being applied to its two individual inputs. In other words, an op-amps output signal is the difference between the two input signals as the input stage of an Operational Amplifier is in fact a differential amplifier as shown below.

Differential Amplifier

The circuit below shows a generalized form of a differential amplifier with two inputs marked V1and V2. The two identical transistors TR1 and TR2 are both biased at the same operating point with their emitters connected together and returned to the common rail, -Vee by way of resistor Re.
operational amplifier basics the differential input
Differential Amplifier
The circuit operates from a dual supply +Vccand -Vee which ensures a constant supply. The voltage that appears at the output, Vout of the amplifier is the difference between the two input signals as the two base inputs are in anti-phase with each other.
So as the forward bias of transistor, TR1 is increased, the forward bias of transistor TR2 is reduced and vice versa. Then if the two transistors are perfectly matched, the current flowing through the common emitter resistor,Re will remain constant.
Like the input signal, the output signal is also balanced and since the collector voltages either swing in opposite directions (anti-phase) or in the same direction (in-phase) the output voltage signal, taken from between the two collectors is, assuming a perfectly balanced circuit the zero difference between the two collector voltages.
This is known as the Common Mode of Operation with the common mode gain of the amplifier being the output gain when the input is zero.
Operational Amplifiers also have one output (although there are ones with an additional differential output) of low impedance that is referenced to a common ground terminal and it should ignore any common mode signals that is, if an identical signal is applied to both the inverting and non-inverting inputs there should no change to the output.
However, in real amplifiers there is always some variation and the ratio of the change to the output voltage with regards to the change in the common mode input voltage is called the Common Mode Rejection Ratio or CMRR.
Operational Amplifiers on their own have a very high open loop DC gain and by applying some form of Negative Feedback we can produce an operational amplifier circuit that has a very precise gain characteristic that is dependant only on the feedback used. Note that the term “open loop” means that there are no feedback components used around the amplifier so the feedback path or loop is open.
An operational amplifier only responds to the difference between the voltages on its two input terminals, known commonly as the “Differential Input Voltage” and not to their common potential. Then if the same voltage potential is applied to both terminals the resultant output will be zero. An Operational Amplifiers gain is commonly known as the Open Loop Differential Gain, and is given the symbol (Ao).

Equivalent Circuit of an Ideal Operational Amplifier

ideal operational amplifier

Op-amp Parameter and Idealised Characteristic

  • Open Loop Gain, (Avo)

    • Infinite – The main function of an operational amplifier is to amplify the input signal and the more open loop gain it has the better. Open-loop gain is the gain of the op-amp without positive or negative feedback and for such an amplifier the gain will be infinite but typical real values range from about 20,000 to 200,000.
  • Input impedance, (Zin)

    • Infinite – Input impedance is the ratio of input voltage to input current and is assumed to be infinite to prevent any current flowing from the source supply into the amplifiers input circuitry ( Iin = 0 ). Real op-amps have input leakage currents from a few pico-amps to a few milli-amps.
  • Output impedance, (Zout)

    • Zero – The output impedance of the ideal operational amplifier is assumed to be zero acting as a perfect internal voltage source with no internal resistance so that it can supply as much current as necessary to the load. This internal resistance is effectively in series with the load thereby reducing the output voltage available to the load. Real op-amps have output impedances in the 100-20kΩ range.
  • Bandwidth, (BW)

    • Infinite – An ideal operational amplifier has an infinite frequency response and can amplify any frequency signal from DC to the highest AC frequencies so it is therefore assumed to have an infinite bandwidth. With real op-amps, the bandwidth is limited by the Gain-Bandwidth product (GB), which is equal to the frequency where the amplifiers gain becomes unity.
  • Offset Voltage, (Vio)

    • Zero – The amplifiers output will be zero when the voltage difference between the inverting and the non-inverting inputs is zero, the same or when both inputs are grounded. Real op-amps have some amount of output offset voltage.
From these “idealized” characteristics above, we can see that the input resistance is infinite, so no current flows into either input terminal (the “current rule”) and that the differential input offset voltage is zero (the “voltage rule”). It is important to remember these two properties as they will help us understand the workings of the Operational Amplifier with regards to the analysis and design of op-amp circuits.
However, real Operational Amplifiers such as the commonly available uA741, for example do not have infinite gain or bandwidth but have a typical “Open Loop Gain” which is defined as the amplifiers output amplification without any external feedback signals connected to it and for a typical operational amplifier is about 100dB at DC (zero Hz). This output gain decreases linearly with frequency down to “Unity Gain” or 1, at about 1MHz and this is shown in the following open loop gain response curve.

Open-loop Frequency Response Curve

operational amplifier frequency response
From this frequency response curve we can see that the product of the gain against frequency is constant at any point along the curve. Also that the unity gain (0dB) frequency also determines the gain of the amplifier at any point along the curve. This constant is generally known as the Gain Bandwidth Product or GBP. Therefore:
GBP = Gain x Bandwidth or A x BW.
For example, from the graph above the gain of the amplifier at 100kHz is given as 20dB or 10, then the gain bandwidth product is calculated as:
GBP = A x BW = 10 x 100,000Hz = 1,000,000.
Similarly, the operational amplifiers gain at 1kHz = 60dB or 1000, therefore the GBP is given as:
GBP = A x BW = 1,000 x 1,000Hz = 1,000,000The same!.
The Voltage Gain (AV) of the operational amplifier can be found using the following formula:
op-amp voltage gain
and in Decibels or (dB) is given as:
op-amp gain in decibels, dB

An Operational Amplifiers Bandwidth

The operational amplifiers bandwidth is the frequency range over which the voltage gain of the amplifier is above 70.7% or -3dB (where 0dB is the maximum) of its maximum output value as shown below.
op-amp frequency response curve
Here we have used the 40dB line as an example. The -3dB or 70.7% of Vmax down point from the frequency response curve is given as 37dB. Taking a line across until it intersects with the main GBP curve gives us a frequency point just above the 10kHz line at about 12 to 15kHz. We can now calculate this more accurately as we already know the GBP of the amplifier, in this particular case 1MHz.

Operational Amplifier Example No1.

Using the formula 20 log (A), we can calculate the bandwidth of the amplifier as:
37 = 20 log A   therefore, A = anti-log (37 ÷ 20) = 70.8
GBP ÷ A = Bandwidth,  therefore, 1,000,000 ÷ 70.8 = 14,124Hz, or 14kHz
Then the bandwidth of the amplifier at a gain of 40dB is given as 14kHz as previously predicted from the graph.

Operational Amplifier Example No2.

If the gain of the operational amplifier was reduced by half to say 20dB in the above frequency response curve, the -3dB point would now be at 17dB. This would then give the operational amplifier an overall gain of 7.08, therefore A = 7.08.
If we use the same formula as above, this new gain would give us a bandwidth of approximately141.2kHz, ten times more than the frequency given at the 40dB point. It can therefore be seen that by reducing the overall “open loop gain” of an operational amplifier its bandwidth is increased and visa versa.
In other words, an operational amplifiers bandwidth is inversely proportional to its gain, ( A 1/∝ BW ). Also, this -3dB corner frequency point is generally known as the “half power point”, as the output power of the amplifier is at half its maximum value as shown:
half power at corner frequency

Operational Amplifiers Summary

We know now that an Operational amplifiers is a very high gain DC differential amplifier that uses one or more external feedback networks to control its response and characteristics. We can connect external resistors or capacitors to the op-amp in a number of different ways to form basic “building Block” circuits such as, Inverting, Non-Inverting, Voltage Follower, Summing, Differential, Integrator and Differentiator type amplifiers.
operational amplifier symbol
Op-amp Symbol
An “ideal” or perfect Operational Amplifier is a device with certain special characteristics such as infinite open-loop gain Ao, infinite input resistance Rin, zero output resistance Rout, infinite bandwidth 0 to and zero offset (the output is exactly zero when the input is zero).
There are a very large number of operational amplifier IC’s available to suit every possible application from standard bipolar, precision, high-speed, low-noise, high-voltage, etc, in either standard configuration or with internal Junction FET transistors.
Operational amplifiers are available in IC packages of either single, dual or quad op-amps within one single device. The most commonly available and used of all operational amplifiers in basic electronic kits and projects is the industry standard μA-741.
741 operational amplifier
In the next tutorial about Operational Amplifiers, we will use negative feedback connected around the op-amp to produce a standard closed-loop amplifier circuit called an Inverting Amplifiercircuit that produces an output signal which is 180o “out-of-phase” with the input.

Saturday, 16 December 2017

How Does Image Upload Controller Is Used JSP Java Programming...

Learning Java Programming Made Easy

Below is the program which uploads the image to the webpage in jsp java program. This program is stored in a jsp controller file and called in form control tag inside view page(html/jsp).





<%--
    Document   : ImageUploadController
    Created on : Oct 4, 2017, 6:40:15 PM
    Author     : HP
--%>

<%@page import="org.w3c.dom.Document"%>
<%@page import="java.io.*,java.util.*, javax.servlet.*" %>
<%@page import="javax.servlet.http.*" %>
<%@page import="org.apache.commons.fileupload.*" %>
<%@page import="org.apache.commons.fileupload.disk.*" %>
<%@page import="org.apache.commons.fileupload.servlet.*" %>
<%@page import="org.apache.commons.io.output.*" %>

<%
   File file ;
   int maxFileSize = 5000 * 1024;
   int maxMemSize = 5000 * 1024;
   String filePath = "C:/Users/HP/Documents/NetBeansProjects/HIbernateWEB/web/ImageStorage/";

   String contentType = request.getContentType();
   
   if ((contentType.indexOf("multipart/form-data") >= 0)) {

      DiskFileItemFactory factory = new DiskFileItemFactory();
      factory.setSizeThreshold(maxMemSize);
      factory.setRepository(new File("c:\\temp"));
      ServletFileUpload upload = new ServletFileUpload(factory);
      upload.setSizeMax( maxFileSize );
      try{ 
         List fileItems = upload.parseRequest(request);
         Iterator i = fileItems.iterator();
         out.println("<html>");
         out.println("<body>");
         
         while ( i.hasNext () ) 
         {
            FileItem fi = (FileItem)i.next();
            if ( !fi.isFormField () )  {
                String fieldName = fi.getFieldName();
                String fileName = fi.getName();
                boolean isInMemory = fi.isInMemory();
                long sizeInBytes = fi.getSize();
                file = new File( filePath + fileName) ;
                fi.write( file ) ;
                
                
    
                out.println("Uploaded Filename: " + filePath + fileName + "<br>");
            }
         }
        
    
         
         out.println("</body>");
         out.println("</html>");
      }catch(Exception ex) {
         System.out.println(ex);
      }
   }else{
      out.println("<html>");
      out.println("<body>");
      out.println("<p>No file uploaded</p>"); 
      out.println("</body>");
      out.println("</html>");
   }
%>



Wednesday, 13 December 2017

How Does Java.Util Pagackage is used in Java?

Learning Java Programming Made Easy




Java.util Package in Java


Java.util Package

It contains the collections framework, legacy collection classes, event model, date and time facilities, internationalization, and miscellaneous utility classes (a string tokenizer, a random-number generator, and a bit array).
Following are the Important Classes in Java.util package :
  1. AbstractCollection: This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface.
  2. AbstractList: This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a “random access” data store (such as an array).
  3. AbstractMap<K,V>: This class provides a skeletal implementation of the Map interface, to minimize the effort required to implement this interface.
  4. AbstractMap.SimpleEntry<K,V>: An Entry maintaining a key and a value.
  5. AbstractMap.SimpleImmutableEntry<K,V>: An Entry maintaining an immutable key and value.
  6. AbstractQueue: This class provides skeletal implementations of some Queue operations.
  7. AbstractSequentialList: This class provides a skeletal implementation of the List interface to minimize the effort required to implement this interface backed by a “sequential access” data store (such as a linked list).
  8. AbstractSet: This class provides a skeletal implementation of the Set interface to minimize the effort required to implement this interface.
  9. ArrayDeque: Resizable-array implementation of the Deque interface.
  10. ArrayList: Resizable-array implementation of the List interface.
  11. Arrays: This class contains various methods for manipulating arrays (such as sorting and searching).
  12. BitSet: This class implements a vector of bits that grows as needed.
  13. Calendar: The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, and so on, and for manipulating the calendar fields, such as getting the date of the next week.
  14. Collections: This class consists exclusively of static methods that operate on or return collections.
  15. Currency: Represents a currency.
  16. Date: The class Date represents a specific instant in time, with millisecond precision.
  17. Dictionary<K,V>: The Dictionary class is the abstract parent of any class, such as Hashtable, which maps keys to values.
  18. EnumMap,V>: A specialized Map implementation for use with enum type keys.
  19. EnumSet: A specialized Set implementation for use with enum types.
  20. EventListenerProxy: An abstract wrapper class for an EventListener class which associates a set of additional parameters with the listener.
  21. EventObject: The root class from which all event state objects shall be derived.
  22. FormattableFlags: FomattableFlags are passed to the Formattable.formatTo() method and modify the output format for Formattables.
  23. Formatter: An interpreter for printf-style format strings.
  24. GregorianCalendar: GregorianCalendar is a concrete subclass of Calendar and provides the standard calendar system used by most of the world.
  25. HashMap<K,V>: Hash table based implementation of the Map interface.
  26. HashSet: This class implements the Set interface, backed by a hash table (actually a HashMap instance).
  27. Hashtable<K,V>: This class implements a hash table, which maps keys to values.
  28. IdentityHashMap<K,V>: This class implements the Map interface with a hash table, using reference-equality in place of object-equality when comparing keys (and values).
  29. LinkedHashMap<K,V>: Hash table and linked list implementation of the Map interface, with predictable iteration order.
  30. LinkedHashSet: Hash table and linked list implementation of the Set interface, with predictable iteration order.
  31. LinkedList: Doubly-linked list implementation of the List and Deque interfaces.
  32. ListResourceBundle: ListResourceBundle is an abstract subclass of ResourceBundle that manages resources for a locale in a convenient and easy to use list.
  33. Locale – Set 1Set 2: A Locale object represents a specific geographical, political, or cultural region.
  34. Locale.Builder: Builder is used to build instances of Locale from values configured by the setters.
  35. Objects: This class consists of static utility methods for operating on objects.
  36. Observable: This class represents an observable object, or “data” in the model-view paradigm.
  37. PriorityQueue: An unbounded priority queue based on a priority heap.
  38. Properties: The Properties class represents a persistent set of properties.
  39. PropertyPermission: This class is for property permissions.
  40. PropertyResourceBundle: PropertyResourceBundle is a concrete subclass of ResourceBundle that manages resources for a locale using a set of static strings from a property file.
  41. Random: An instance of this class is used to generate a stream of pseudorandom numbers.
  42. ResourceBundle: Resource bundles contain locale-specific objects.
  43. ResourceBundle.Control: ResourceBundle.Control defines a set of callback methods that are invoked by the ResourceBundle.getBundle factory methods during the bundle loading process.
  44. Scanner: A simple text scanner which can parse primitive types and strings using regular expressions.
  45. ServiceLoader: A simple service-provider loading facility.
  46. SimpleTimeZone: SimpleTimeZone is a concrete subclass of TimeZone that represents a time zone for use with a Gregorian calendar.
  47. Stack: The Stack class represents a last-in-first-out (LIFO) stack of objects.
  48. StringTokenizer: The string tokenizer class allows an application to break a string into tokens.
  49. Timer: A facility for threads to schedule tasks for future execution in a background thread.
  50. TimerTask: A task that can be scheduled for one-time or repeated execution by a Timer.
  51. TimeZone: TimeZone represents a time zone offset, and also figures out daylight savings.
  52. TreeMap<K,V>: A Red-Black tree based NavigableMap implementation.
  53. TreeSet: A NavigableSet implementation based on a TreeMap.
  54. UUID: A class that represents an immutable universally unique identifier (UUID).
  55. Vector: The Vector class implements a growable array of objects.
  56. WeakHashMap<K,V>: Hash table based implementation of the Map interface, with weak keys.

How Does java.lang package is used in java?

Learning Java Programming Made Easy



Java.lang package in Java


Java.lang package in Java

Provides classes that are fundamental to the design of the Java programming language. The most important classes are Object, which is the root of the class hierarchy, and Class, instances of which represent classes at run time.
Following are the Important Classes in Java.lang package :
  1. Boolean: The Boolean class wraps a value of the primitive type boolean in an object.
  2. Byte: The Byte class wraps a value of primitive type byte in an object.
  3. Character – Set 1, Set 2: The Character class wraps a value of the primitive type char in an object.
  4. Character.Subset: Instances of this class represent particular subsets of the Unicode character set.
  5. Character.UnicodeBlock: A family of character subsets representing the character blocks in the Unicode specification.
  6. Class – Set 1Set 2 : Instances of the class Class represent classes and interfaces in a running Java application.
  7. ClassLoader: A class loader is an object that is responsible for loading classes.
  8. ClassValue: Lazily associate a computed value with (potentially) every type.
  9. Compiler: The Compiler class is provided to support Java-to-native-code compilers and related services.
  10. Double: The Double class wraps a value of the primitive type double in an object.
  11. Enum: This is the common base class of all Java language enumeration types.
  12. Float: The Float class wraps a value of primitive type float in an object.
  13. InheritableThreadLocal: This class extends ThreadLocal to provide inheritance of values from parent thread to child thread: when a child thread is created, the child receives initial values for all inheritable thread-local variables for which the parent has values.
  14. Integer :The Integer class wraps a value of the primitive type int in an object.
  15. Long: The Long class wraps a value of the primitive type long in an object.
  16. Math – Set 1, Set 2: The class Math contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
  17. Number: The abstract class Number is the superclass of classes BigDecimal, BigInteger, Byte, Double, Float, Integer, Long, and Short.
  18. Object: Class Object is the root of the class hierarchy.
  19. Package: Package objects contain version information about the implementation and specification of a Java package.
  20. Process: The ProcessBuilder.start() and Runtime.exec methods create a native process and return an instance of a subclass of Process that can be used to control the process and obtain information about it.
  21. ProcessBuilder: This class is used to create operating system processes.
  22. ProcessBuilder.Redirect: Represents a source of subprocess input or a destination of subprocess output.
  23. Runtime: Every Java application has a single instance of class Runtime that allows the application to interface with the environment in which the application is running.
  24. RuntimePermission: This class is for runtime permissions.
  25. SecurityManager: The security manager is a class that allows applications to implement a security policy.
  26. Short: The Short class wraps a value of primitive type short in an object.
  27. StackTraceElement: An element in a stack trace, as returned by Throwable.getStackTrace().
  28. StrictMath: The class StrictMath contains methods for performing basic numeric operations such as the elementary exponential, logarithm, square root, and trigonometric functions.
  29. String: The String class represents character strings.
  30. StringBuffer: A thread-safe, mutable sequence of characters.
  31. StringBuilder: A mutable sequence of characters.
  32. System: The System class contains several useful class fields and methods.
  33. Thread: A thread is a thread of execution in a program.
  34. ThreadGroup: A thread group represents a set of threads.
  35. ThreadLocal: This class provides thread-local variables.
  36. Throwable: The Throwable class is the superclass of all errors and exceptions in the Java language.
  37. Void: The Void class is an uninstantiable placeholder class to hold a reference to the Class object representing the Java keyword void.

How Does java.io pacakage in Java Programming ?

Learning Java Programming Made Easy



Java.io Package in Java


Java.io Package in Java


This package provides for system input and output through data streams, serialization and the file system. Unless otherwise noted, passing a null argument to a constructor or method in any class or interface in this package will cause a NullPointerException to be thrown.
Following are the important classes in Java.io package:
  • BufferedInputStream
  • BufferedOutputStream
  • BufferedReader
  • BufferedWriter
  • ByteArrayInputStream
  • ByteArrayOutputStream
  • CharArrayReader
  • CharArrayWriter – Set1 Set2
  • Console
  • DataInputStream – Set1 Set2
  • DataOutputStream
  • File
  • FileDescriptor
  • FileInputStream
  • FileOutputStream
  • FilePermission
  • FileReader and FileWriter
  • FilterInputStream
  • FilterOutputStream
  • FilterReader
  • FilterWriter
  • InputStream
  • InputStreamReader
  • LineNumberInputStream
  • LineNumberReader
  • ObjectInputStream
  • ObjectInputStream.GetField
  • ObjectOutputStream – Set 1 Set2
  • ObjectOutputStream.PutField
  • ObjectStreamClass
  • ObjectStreamField
  • OutputStream
  • OutputStreamWriter
  • PipedInputStream
  • PipedOutputStream
  • PipedReader
  • PipedWriter
  • PrintStream – Set1   Set2
  • PrintWriter – Set1  Set2
  • PushbackInputStream
  • PushbackReader
  • RandomAccessFile
  • Reader
  • SequenceInputStream
  • SerializablePermission
  • StreamTokenizer – Set1 Set2
  • StringBufferInputStream
  • StringReader
  • StringWriter
  • Writer
  • ZipInputStream class in Java
  • ZipEntry class in Java
  • JarEntry class in Java
  • ZipOutputStream class in Java
  • Zip.InflaterInputStream class in Java
  • Zip.DeflaterInputStream class in Java
  • Zip.DeflaterOutputStream class in Java

Sunday, 10 December 2017

How to write Java program to get a list of all file/directory names from the given

Learning Java Programming Made Easy


Here is an example program to get the list of all file/directory names from the given link...

Please try this by your self and learn..



import java.io.File; import java.util.Date; public class Exercise1 { public static void main(String a[]) { File file = new File("/home/students/"); String[] fileList = file.list(); for(String name:fileList){ System.out.println(name); } } }

Charactor_At_Position

public class Char_At_Position { public static void main(String[] args) { String str = "Wankhede"; String rev=""...