Posts

C Interview Link

Image
Question Rating View Answer What does it mean when a pointer is used in an if statement? View Answer When would you use a pointer to a function? View Answer Why should we assign NULL to the elements (pointer) after freeing them? View Answer What is file pointer and its working method? View Answer What is indirection? View Answer Following declarations are same const char *s; char const *s; View Answer Difference between :- 1) NULL pointer and NULL macro ? View Answer What is the difference between far and near? View Answer WRITE A C PROGRAMME TO FIND OUT THE AREA OF A CIRCLE USING POINTER. View Answer Why should we assign NULL to the elements (pointer) after freeing them ? View Answer In the following code, what is p2? typedef int* ptr ptr p1, p2; View Answer What do you mean by normalisation of pointers View Answer Difference between arrays and pointers? View Answer Between a long pointer and a char pointer , which one consumes more memo...

Difference Between ArrayList,Vector,LinkList?

ArrayList  Think of this as a growable array. It gives you fast iteration and fast random access. To state the obvious: it is an ordered collection (by index), but not sorted.ArrayList now implements the new RandomAccess interface—a marker interface (meaning it has no methods)  that says, "this list supports fast (generally constant time) random access." Choose this over a LinkedList when you need fast iteration but aren't as likely to be doing a lot of insertion and deletion. Vector  Vector is a holdover from the earliest days of Java; Vector and Hashtable were the two original collections,A Vector is basically the same as an ArrayList, but Vector methods are syn- chronized for thread safety. You'll normally want to use ArrayList instead of Vector because the synchronized methods add a performance hit you might not need. And if you do need thread safety, there are utility methods in class Collections that can help. Vector is the only class other ...

Java Collections Framework

Part of Collections Framework Collection          Collection Subtypes: The following interfaces (collection types) extends the Collection interface:   1.  List   2.  Set   3. SortedSet   4. NavigableSet   5. Queue   6. Deque  Example : import java . util .*; import java . util . Collection ; public class collectioninterface { public static void main ( String [] args ) { Collection collection = new ArrayList (); collection . add ( "Dev" ); collection . add ( "Manuals" ); System . out . print ( " Elements Of the Array List are " ); System . out . print ( collection + "." ); } }     Set     Set Interface in Java:- The Set interface extends the Collection interface. A Set is a Collection that cannot contain duplicate elements. Not only must these elements be unique, but while they are in the set, each element must not be ...

Anonymous Inner Classes?

The inner class which is declared inside the body of a method is known as the local inner classes . The class declared inside the body of a method without naming it is known as anonymous inner classes. class popcorn {        public void pop       {            System.out.println("popcorn");       } } class food (      popcorn p = new popcorn()     {           public void pop       {            System.out.println("anonymous popcorn");       }     }; ) Example 2: button . addActionListener ( new ActionListener () { public void actionPerfored ( ActionEvent e ) { // do something. } }); Note: Anonymous inner class have no name,and theire type must be either a subclass of the name type or the implementor of the...

What are Class loaders? Explain the types of class loader

Class loaders are the part of the Java Runtime Environment that dynamically loads Java classes into the Java virtual machine. It is responsible for locating libraries, reading there content and loading the classes contained within the libraries. When JVM is started three class loaders are used 1. Bootstrap class loader 2. Extensions class loader 3. System class loader Bootstrap class loader loads the core java libraries. It is written in native code. The bootstrap class loader is responsible for loading key java classes like java.lang.Object and other runtime code into memory. The runtime classes are packaged inside jre/lib/rt.jar file. Extensions class loader loads the code in the extension directories. It is implemented by ExtClassLoader class. System class loader the code found on the j...

What is an interface and how will you go about implementing an interface?

Interface is a set of protocols which are used to define the structure of an application. They support multiple interface inheritance. An interface can contain variable. These variables by default are public static final. Interfaces are by default abstract. An interface can contain only abstract methods. Interfaces are implemented in class by using the implements keyword. In interfaces the methods or functions are declared only, they are defined in the class.For example Interface a { Int n1=5; Void s(); Void s1(); } //full implementation of the interface class b implements a { public void s() { System.out.println(“Hello s”); } public void s1() ...

Difference between throw and throws clause?

A program can throw an exception, using throw statement. When an exception is thrown, normal execution is suspended. The runtime system proceeds to find a catch block that can handle the exception. The exceptions are caught under the Exception class. This class is used for giving user defined exception. To use this class throw keyword is used. //Program using throw keyword class check_age extends Exception// inheriting the exception class { public String toString() { return "Age cannot be less than 18"; } static void age(int a) { try// to handle exception try and catch block is given { if(a<18) { check_age obj= new check_age(); throw obj;...