In computer science, a hash table, or a hash map, is a data structure that associates keys with values. The primary operation it supports efficiently is a lookup: given a key (e.g. a person's name), find the corresponding value (e.g. that person's telephone number). It works by transforming the key using a hash function into a hash, a number that is used as an index in an array to locate the desired location ("bucket") where the values should be. Hash tables support the efficient insertion of new entries, in expected O(1) time. The time spent in searching depends on the hash function and the load of the hash table; both insertion and search approach O(1) time with well chosen values and hashes.
Object oriented design and procedural oriented design?
In object oriented programming main role plays objects and classes, in structure programming all programmes are represented as structures of block's, in procedure programming - that means high level programming languages, which are based on process description (sequence of processes) - all programmes are described like a set of subprogrammes or procedures.
For more information you may search these articles:
http:/en.wikipedia.org/wiki/Object-oriented_programming
http://alarmingdevelopment.org/?p=9
http:/en.wikipedia.org/wiki/Procedural_programming
What is the purpose of a function or procedure?
function is a set of statements that can be executed in the part of the program.
ex: to add two nos. using function
void main()
{
int a,b,c;
printf("enter the two numbers");
scanf("%d%d",&a,&b);
add(a,b);
clear();
}
void add(int a,int b)
{
c=a+b;
printf("the sum is %d",c);
}
Can we write static public void main in java?
the method of an class that can is triggered when starting a Java application e.g. by running the command: "java MyProgram"
Answer
Public is an Access Specifier,static is a keyword which illustrates that method shared along all the classes.void illustrates that this method will not have any return type.main is the method which string has an argument. Public specifier makes the method visible outside the Class and because of the static nature of the method, JVM can call this main method without instantiating the class 'MyProgram'.
Declaration can appear anywhere in the body of java method ATrue B False?
Partially true and partially false.
A variable's declaration must happen atleast one life before the usage of that variable. Therefore we can take this as declaration can be done anywhere provided we declare it before the usage. otherwise it would throw a compilation error.
What is purpose of abstraction in java?
Abstract keyword used for method declaration declares the methods without implementations.
Abstract class in java have abstract methods that is not implemented in abstract class, but implemented in subclasses in java program. If the class in java program is not required to get instantiated than that class use the abstract keyword but this class rather is available for other classes to extend by other classes.
Abstract keyword will be used in method declaration to declare that method without providing the implementation in that java program. In other words we can say that, it formally unfinished class as well as method, that marked with the help of keyword abstract.
Defining abstract is a way of preventing someone from instantiating a class that is supposed to be extended first. In java program abstract class is deliberately missing similar to like an interface which will missing all method bodies in the program. Abstract class provides a way to extend an actual class. We will not use new on abstract classes but will use abstract references in the java program, that always point to objects of the class that extends an abstract class.
In java program for practical use of an abstract class, we will define a non-abstract class that extends an abstract one. This will use any of the inherited non-abstract methods.
Most of the time abstract class may extend another abstract class. In that condition it need not implement all in the non-abstract methods. An abstract keyword used both on classes and methods. In case of class declared with an abstract keyword may not be instantiated that is the only thing that abstract keyword doing.
How operator overloading differ from function overloading?
Function overloading is multiple definition with different signatures(the parameters should be different) for the same function. The parameter list have to be different in each definition. The compiler will not accept if the return type alone is changed.
Operator overloading is defining a function for a particular operator. The operator loading function can not be overloaded through function overloading.
Actually, the Java compiler is not considered slow when compared to compiling a similar project in C or C++. The Java compiler itself is actually quite simple. All of the fancy Java optimizations occur during runtime.
As someone who used to work on the Sun JDK at Sun itself, I can tell you that the old javac (pre-2010 or so) was rather simplistic. Remember that javac itself is a Java program, so that to run, it must first invoke a JVM, and incurs typical JVM load and initialization time. It was originally designed to work on the 'fork/exec' model so common to UNIX, where it would fork a new instance of javac (and the associated JVM required to run it) for every file that it compiled. Now, creating a new JVM had significant startup time costs (initialization of methods was nontrivial), but javac would run reasonably fast one that happened. However, having to fork several hundred times during a single project compile got expensive, and slow. This was particularly true on Windows, where a 'fork/exec' call is over 10x as slow as on a UNIX or Linux system.
So, the 'old' javac, while quite quick to actually compile a single file after it got running, was actually quite slow overall when forced to compile a large number of source code files.
A major revamp of the javac compiler was undertaken during 2010 with JDK 7. This revamp significantly reduced the number of times a fork/exec was done, buy reusing existing JVMs to run several (sequential) invocations of the javac language. This significantly improved large project compile times, as it reduced the primary overhead that was slowing things down. There are additional projects being worked on that will turn javac into a single multi-threaded program able to compile multiple files itself in one invocation, thus eliminating the need to spawn multiple JVMs. This will particularly help Windows compiles, as Windows threading is much faster than fork/exec.
So, overall, if you are running a JDK with a javac created BEFORE mid-2010, javac will be relatively slow for compiling lots of source files, and worse on Windows. Pretty much all Sun/Oracle JDK 6 versions (even the newest ones) have this "defective" javac. The newer, faster javac is available in JDK 7 - I believe it may not be in JDK7, but is definitely in JDK 7 Update 1 and later. This javac should feel quite responsive for most projects, and only be a bit slow on large Windows compiles (more than 100 source files or so), and, even there, will be a noticeable improvement over the JDK 6 javac program.
What is Thread Synchronization?
Thread synchronization requires that a running thread gain a "lock" on an object before it can access it. The thread will wait in line for another thread that is using the method/data member to be done with it. This is very important to prevent the corruption of program data if multiple threads will be accessing the same data. If two threads try to change a variable or execute the same method at the same, this can cause serious and difficult to find problems. Thread synchronization helps prevent this.
Many programming languages, operating systems, and other software development environments support what are called "threads" of execution. Threads are similar to processes, in that both represent a single sequence of instructions executed in parallel with other sequences, either by time slicing or multiprocessing. Threads are a way for a program to split itself into two or more simultaneously running tasks. (The name "thread" is by analogy with the way that a number of threads are interwoven together)
What is a Java program that finds the greatest common factor of two integers?
The easiest way to find the greatest common denominator of two integers with a computer program is to use the Euclidean algorithm. Of the most popular methods of finding the GCD of two numbers, the Euclidean algorithm does it with the least amount of work and requires the least amount of code.
In order to understand the Euclidean algorithm, you'll need to know a few division terms:
A is the dividend, B is the divisor, C is the quotient, and D is the remainder.
The Euclidean algorithm works like this:
If you still don't get it, try looking at the Euclidean algorithm in action:
Find the GCD of 84 and 18.
You should now have a good grasp of how the Euclidean algorithm works. Now we need to turn it into code. We'll need three variables, all of them integers:
int divisor, dividend, remainder;
The purpose of the variables is self-explanatory. Next, we need to make a few decisions. We need to decide if the dividend or the divisor is 0. If that test is passed, then we need to decide if the dividend or the divisor is 1. If that test is passed, then we need make sure that dividend is larger than divisor.
if(dividend 1) {
printf("The GCD is 1.\n");
}
// Make sure the dividend is greater than the divisor.
if(divisor > dividend) {
remainder = dividend;
dividend = divisor;
divisor = remainder;
}
// Calculate the GCD.
while(remainder != 0) {
remainder = dividend % divisor;
dividend = divisor;
divisor = remainder;
}
// Display the answer to the user.
printf("The GCD is %i.\n", dividend);
}
And the GCD lived happily ever after. The end.
Can you define a constructor as private?
I dont think we can have Protected Constructors but yes we can have Private constructors.
We can declare the constructor as Private to ensure that no other class can instantiate it. We use this in the singleton design pattern
What is class in oops concept?
Classes are the integral part of the all-important programming paradigm known as Object-Oriented Programming(OOP). In OOP, a programming problem is perceived as a problem in a real-life scenario, as an interaction between objects. The problem is tackled by having a system of interacting objects, that interact among themselves to solve the programming problem. Objects in OOP bear semblance to real-life objects. Classes serve as templates for the creation of objects of the same type. For instance, students may be thought to be objects of the human-being class, cars may be thought to be objects of the Automobile class. Classes are defined as collection of methods(functions) and data members(variables), additionally defined by scope rules. In addition, classes also achieve the OOP principles of encapsulation, abstraction, polymorphism and inheritance. Encapsulation refers to binding data and code together, with data controlling access to code. Abstraction refers to the hiding the implementation details of a class from outside functions and exposing only necessary details. Polymorphism refers to the scenario when a class can play more than one role. Inheritance is used when one or more classes must include properties of another set of classes, and also have properties of their own.
A data type consisting of more than one letter, like a word or a sentence. A single letter is normally known as a character data type. Normally strings are enclosed in double quotation marks and single letters are enclosed in single quotations marks:
'a'
"animal"
How can Boolean be used in Java?
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
An expression is anything that can be evaluated ("calculated"), to get a value. Numeric expressions are more common: anything that you can calculate, and get a number. For example, if a and b are numbers, a + b will give you another number - it is therefore a numeric expression. The variables by themselves are also numeric expressions.
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
a == b
a > b
a >= 5 && a <= 10 // && means "and"
Any method that returns either true or false, for example (for the String class) the method matches(), which states whether the string does, or does not, match a certain pattern.
Any kind of sequential program is not a good candidate to be threaded. An example
of this is a program that calculates an individual tax return. (2) Another example is a
"shell" program such as the C-shell or Korn shell. Such a program must closely
monitor its own working space such as open files, environment variables, and
current working directory.
Data types in c primitive and non primitive?
Primitive types are the data types provided by a programming language as basic building blocks. Primitive types are also known as built-in types or basic types.
Depending on the language and its implementation, primitive types may or may not have a one-to-one correspondence with objects in the computer's memory. However, one usually expects operations on primitive types to be the fastest language constructs there are. Integer addition, for example, can be performed as a single machine instruction
What is the different between java applets java application?
Servlets is a application that running on the server, when a server receive a request of a servlet, the server will process the servlet and give the result to the client back after the servlet is done.
WAP to print sum and average of multiples of 5 from 500 to 600?
public class Test {
public static void main(String[] args){
int i = 500;
int sum = 0;
int avg = 0;
int counter = 0;
do {
i = i + 5;
sum = sum + i;
counter = counter + 1;
} while (i <= 600);
System.out.println("Sum: " + sum);
avg = sum/counter;
System.out.println("Average: " + avg);
}
}
What is the difference between streaming and buffering?
Streaming is when your computer takes data when it needs it, because your connection is fast enough to do it almost instantly. Buffering usually occurs on slower connections, because the program needs a "buffer" so it will not catch up to the unloaded section and cause delays (it usually doesnt' work).
I am learning java next what you want me to read?
Java is an object-oriented programming language that is generally designed either to be compiled into native (machine) code or to be interpreted from source code at runtime. Java is intended to be compiled into a byte code, which is then run (generally using JIT compilation) by a Java Virtual Machine. Java training curriculum has been designed in such a way that it provides a proper understanding of Java Programming along with different features like file handling, string handling, threading, etc.
Java is platform-independent and is used to develop Console Applications, Desktop Applications, and Web Applications. Java also supports multi-threading which helps it to perform multiple tasks at the same time. IT DESK promotes Java Training courses to the students to do Internships and all the Training is given on the latest version of Java. at our institutes all over India
false
How do you use keywords to reinforce your message?
Serve to remind the speaker of the ideas in the correct order