What is the difference between throw and throws in Java?
Throw is used to actually throw the exception, whereas throws is declarative for the method. They are not interchangeable.
public void myMethod(int param) throws MyException
{
if (param < 10)
{
throw new MyException("Too low!);
}
//Blah, Blah, Blah...
} The Throw clause can be used in any part of code where you feel a specific exception needs to be thrown to the calling method.
If a method is throwing an exception, it should either be surrounded by a try catch block to catch it or that method should have the throws clause in its signature. Without the throws clause in the signature the Java compiler does not know what to do with the exception. The throws clause tells the compiler that this particular exception would be handled by the calling method.
What is the difference between pthread and thread?
Answer POSIX threads are fairly portable. They can be emulated on uniprocessor systems at a slight (or sometimes no) penalty in speed. On shared memory multiprocessor machines, there is often kernel support for threads; this means that your application can take full advantage of all available CPUs and achieve (near) maximum performance. It is important to point out that threads libraries are predicated on shared memory. Threads won't help you on distributed memory machines Preeti
Explain the differences between Assembly Language and High Level Language?
Assembly language is used to write programs using the instruction set for a particular processor/controller.(example : 8051 or 8086 or MIPS).
Assembly Language require an ASSEMBLER to convert the assembly code to machine level code(HEX CODE)
High Level Language require a Compiler to convert into ASSEMBLY THEN machine level code.(Now-a-days compilers are smart enough to generate the machine code directly)
To write assembly code it is necessary to know the architecture of the processor or controller.
To write an High Level Program it is not neccessay to know the architecture completly.
Assembly language is not protable.
High Level Language is Portable.
with regards
Mohan Kumar.J
MCIS,
MANIPAL.
Assembly language is used to write programs using the instruction set for a particular processor/controller.(example : 8051 or 8086 or MIPS).
High Level Language is used to write programs using some grammer rules or languages created like C,PASCAL,FORTRN,JAVA.
Assembly Language require an ASSEMBLER to convert the assembly code to machine level code(HEX CODE)
High Level Language require a Compiler to convert into ASSEMBLY THEN machine level code.(Now-a-days compilers are smart enough to generate the machine code directly)
To write assembly code it is necessary to know the architecture of the processor or controller.
To write an High Level Program it is not neccessay to know the architecture completly.
Assembly language is not protable.
High Level Language is Portable.
with regards
Mohan Kumar.,
MCIS,
MANIPAL.
EACH HLL INSTRUCTION SPECIFY SEVERAL INSTRUCTIONS IN isa OF COMPUTER. WHEREAS EACH aSSEMBLY LEVEL INSTRUCTION SPECIFIES A SINGLE INSTRUCTION IN ISA OR MACHINE LEVEL LANGUAGE
PRIYA BAJAJ
WIPRO TECHNOLOGIES
BANGALORE
Answer--Assembly language :-A programming language that is once removed from a computer's machine language. Machine languages consist entirely of numbers and are almost impossible for humans to read and write. Assembly languages have the same structure and set of commands as machine languages, but they enable a programmer to use names instead of numbers.
Each type of CPU has its own machine language and assembly language, so an assembly language program written for one type of CPU won't run on another. In the early days of programming, all programs were written in assembly language. Now, most programs are written in a high-level language such as FORTRAN or C. Programmers still use assembly language when speed is essential or when they need to perform an operation that isn't possible in a high-level language.
High-level language:-
-JP Morgan
A programming language such as C, FORTRAN, or Pascal that enables a programmer to write programs that are more or less independent of a particular type of computer. Such languages are considered high-level because they are closer to human languages and further from machine languages. In contrast, assembly languages are considered low-level because they are very close to machine languages.
The main advantage of high-level languages over low-level languages is that they are easier to read, write, and maintain. Ultimately, programs written in a high-level language must be translated into machine language by a compiler or interpreter.
The first high-level programming languages were designed in the 1950s. Now there are dozens of different languages, including Ada, Algol, BASIC, COBOL, C, C++, FORTRAN, LISP, Pascal, and Prolog.
An assembly language is where each statement corresponds to one machine instruction. A high level language is where each statement corresponds to more than one, sometimes many, machine instructions.
Why is Microsoft Word not used for writing HTML coding?
They are not text editors. They will have a lot of hidden characters in them that can disrupt the file. Along with the actual text, it will include the data that defines the font and the size and so on, and they all become part of the file. A HTML file should be done in a pure text editor and only have text in it. Formatting should not be important in the text itself. Then the browser will be able to read the file without being disrupted by other things in the file. Only if you can save the file as text only, would you use something that is not a text editor.
Why Customers prefer to develop their applications using Java or Dot net frame work?
Because that's the whole purpose of a programming language, the reason why they were developed - to make software.
Because that's the whole purpose of a programming language, the reason why they were developed - to make software.
Because that's the whole purpose of a programming language, the reason why they were developed - to make software.
Because that's the whole purpose of a programming language, the reason why they were developed - to make software.
How To find a maximum number in a 2D array?
// Pseudocode
int findMax( int[][] data ) {
// Return if data is empty
if( data.length 0 ) {
return 0;
}
int max = data[0][0];
// Iterate through each element in the array
for( int r = 0; r < data.length; ++r ) {
for( int c = 0; c < data[0].length; ++c ) {
// If we find a value greater than the current max, update max
if( data[r][c] > max ) {
max = data[r][c];
}
}
}
return max;
}
When was the programming language C Sharp initially developed or released?
It was developed by Microsoft during 2000-01. A beta version was released in October 2001 and a full version was out in April 2002.
During the development of the .NET Framework, the class libraries were originally written using a managed code compiler system called Simple Managed C (SMC). In January 1999, Anders Hejlsberg formed a team to build a new language at the time called Cool, which stood for "C-like Object Oriented Language". Microsoft had considered keeping the name "Cool" as the final name of the language, but chose not to do so for trademark reasons. By the time the .NET project was publicly announced at the July 2000 Professional Developers Conference, the language had been renamed C#, and the class libraries and ASP.NET runtime had been ported to C#.
C# First Language specification was given on December 2001
and its First Version was released on January 2002
ASP means, Active Server Pages. An Active Server Page is a web page that includes program code that is processed on a Microsoft web server before the page is sent to the user. The code is typically used to access data from a database and that data is then built into the returned web page "on the fly". ASP was developed by Microsoft and is a feature of Microsoft's web server software, but the dynamically generated pages can be viewed by almost any browser. Because at run-time the code is translated to html+JavaScript code
What is the difference between VB and Visual Studio?
I believe visual studio is the user interface, and it not only supports visual basic but also visual c++, c#, web development etc. Visual basic, on the other hand, is a programming language.
What was the difference between java and net?
Net survives because of java. Net is made up of java.
Internet is a huge network which can be accessed by various users throughout the world. They can use different platforms(or operating systems) which may cause problems like a web page designed for windows may not work with Linux.
Therefore to get rid of this problem java is used to design the internet which is
platform independent.
That is why, net and java are almost same but none is better although net has
got some additional features like flash,etc. with time.
What is the importance of recursion in computer programming?
Recursion is important because many algorithms are naturally recursive, particularly those that involve a divide-and-conquer technique. That is, we divide a complex problem into smaller instances of the same problem. Each division divides and reduces the problem further until the divisions are small enough to be resolved. We then aggregate those individual solutions to solve the original problem.
As a simple example, factorials can be calculated such that f(n) = n * f(n-1) for all n>1 where f(1) and f(0) are both 1. We can implement this function recursively as follows:
unsigned f(unsigned n) {
return n<2 ? 1 : n * f(n-1);
}
While the function itself is naturally recursive, that doesn't mean we must use a recursive solution. In this case, an iterative solution would actually be more efficient:
unsigned f(unsigned n) {
unsigned a = 1;
while (1<n) a *= n--;
return a;
}
However, in languages that allow compile-time computation (such as C++), recursive functions can be advantageous:
constexpr unsigned f(unsigned n) {
return n<2 ? 1 : n * f(n-1);
}
With this function, a good compiler will convert f(6) to the literal constant 720, completely eliminating the runtime overhead of invoking the function recursively. However, for values that cannot be computed at compile time due to excessive recursions, the runtime function will still be invoked, such that f(10) might be replaced with the constant expression 10 * f(9).
Languages that support template metaprogramming can provide the means to completely eliminate the runtime overhead associated with recursion:
template <unsigned N>
constexpr unsigned f () {
return N*f<N-1>();
}
template<>
constexpr unsigned f<1>() {
return 1;
}
template<>
constexpr unsigned f<0>() {
return 1;
}
Note that the terminating conditions are handled through specialisation rather than through recursion. At compile time, f<1>() invokes the first specialisation while f<0>() invokes the second. For all values N>1, the general function is invoked recursively at compile time.
constexpr unsigned x = f<10>();
Compile-time computation will effectively replace the above expression with:
constexpr unsigned x = 3628800;
Note that no code is generated for these template functions so we cannot invoke them at runtime, they are used purely for compile-time computation.
In languages that do not support template metaprogramming or constexpr, we can still make use of recursion, particularly where an iterative approach is too complex to implement efficiently. Divide-and-conquer algorithms are a typical example.
The Quicksort algorithm is a relatively simple recursive algorithm that can be implemented as follows:
void qsort (int a[], int lo, int hi) {
if (hi<=lo) return;
unsigned pivot = partition (a, lo, hi);
qsort (a, lo, pivot-1);
qsort (a, pivot+1, hi);
}
The partition() function does most of the actual work. Given the lower and upper bounds of the array it will select a pivot value and position this value such that all values to the left of it are less than it and all those to the right are not less than it. Once the array is partitioned, the index of the pivot value is returned. This value is used to determine the upper bound of the left sub-array (pivot-1) and the lower bound of the right sub-array (pivot+1).
What are the different types of data types used in c.net?
In C#, data types can be categorised as
Value Types
Variables defined from Value Types store values. Copying one value type caribale tp another, doesn't affect the priginal vraible.
They can be further categorised into: -
1) structs: - They can be numeric (int, float, decimal), bool, user-defined structs.
2) Enumerations: - They consist of a set of named constants. By default the first enumerator has value=0.
Reference Types
These objects store references to the actual data. These can be categorised into: -
1) Classes: -- They encapsulate data and its functionality into a single entity called OBJECT.
2) Interfaces: - These are used to declare the signatures, blurprints of methods, delegates and events.
3) Delegates: - These contain the addresses/references to a method.
For more information refer to related links.
How do you find the square root of a number in C?
You write a function that evaluates the square root of its argument and returns the result to the caller.
You can also use the run-time library functions in math.h ...
double sqrt (double x);
double pow (double x, (double) 0.5);
Is it necessary to implement all the methods of abstract classes in derived class?
An Abstract class is a way to organize inheritance, sometimes it makes no since to implement every method in a class (i.e. a predator class), it may implement some to pass to its children but some methods cannot be implemented without knowing what the class will do (i.e. eat() in a Tiger class). Therefore, abstract classes are templates for future specific classes.
A disadvantage is that abstract classes cannot be instantiated, but most of the time it is logical not to create a object of an abstract class. heloooooo
C sharp dot net example programs for beginers?
using System;
using System.Collections.Generic;
using System.Text;
namespace Average_of_three_Nos
{
class Program
{
static void Main(string[] args)
{
string no1, no2, no3;
int n1, n2, n3;
int average;
Console.WriteLine("Enter First Number");
no1 = Console.ReadLine();
n1 = Int32.Parse(no1);
Console.WriteLine("Enter Second Number");
no2 = Console.ReadLine();
n2 = Int32.Parse(no2);
Console.WriteLine("Enter third Number");
no3 = Console.ReadLine();
n3 = Int32.Parse(no3);
average = (n1 + n2 + n3) / 3;
Console.WriteLine("Average of three Numbers : "+ average);
}
}
}
Program #2:This program will take two positive numbers as its input and then find GCD of them.
using System;
using System.Collections.Generic;
using System.Text;
namespace GCD
{
class Program
{
static void Main(string[] args)
{
Program obj = new Program();
string no1, no2;
int n1, n2;
Console.WriteLine("Enter First Number");
no1 = Console.ReadLine();
n1 = Int32.Parse(no1);
Console.WriteLine("Enter Second Number");
no2 = Console.ReadLine();
n2 = Int32.Parse(no2);
int g=obj.find_gcd(n1, n2);
Console.WriteLine("GCD=" + g);
}
int find_gcd(int a, int b)
{
int c;
if(a
{
c = a;
a = b;
b = c;
}
while(true)
{
c = a%b;
if(c==0)
return b;
a = b;
b = c;
}
}
}
}
What is the difference between static and dynamic programming?
in static programming properties, methods and object have to be declared first, while in dynamic programming they can be created at runtime. This is usually due to the fact that the dynamic programming language is an interpreted language.
In the spaceship framework, humans share the limited resoursed of the Earth; in the lifeboat framework, there are enough resources for some and not others. -apex :)
Method overloading is when you have multiple methods in a class that have the same name but a different signature.
Ex:
public void print (String s){
}
public void print(int a) {
}
If we use more than one same type of method but different parameters or parameter list with same no. of parameters within same class than it is called methodoverloading.
if we use more than one different type of method within same class than we dont call it method overloading
for example:
public void add(int a , int b){
systemout.println(a+b);
}
public void add(double a , double b){
systemout.println(a+b);
}
public void add(string a , string b){
systemout.println(a+b);
}
What is a member of a class that cannot be externally used?
There are several different keywords in .Net languages that are used to define the "accessability" of a member or method. For example, in C#, the "private" keyword is used to indicate that this member or method cannot be accessed by any instance of the class, nor by any class that inherits from the class. "Protected" is similar to "private" but allows inherited classes to acces those members. "Internal" allows access to those members freely to any class that is also declared in the same assembly.
How do you send message to networked computer with command prompt?
Method 1 You can use the Net Send command which is a messaging service provided by Microsoft allows users to sends messages to other users, computers, or messaging names on the network. Messenger Service should be started on user's computer. The syntax of the Net Send command net send {name | * | /domain[:name] | /users} message Method 2 Use third party LAN messenger. Since the net send command line may not efficient and convenient for daily office communication. Using a specified LAN messenger to transfer message is more popular today. THe link below is a comparison between the advantages and disadvantages of net send command line and LAN messenger.
Compare Hofstede's cultural dimensions with the GLOBE framework?
Hofstede's framework for assessing cultures began in the late 1970's, while in the later future, the GLOBE framework for assessing cultures began in 1993.
Hofstede based his survey on IBM workers in 40 countries and found that both managers and employees vary on five value dimensions of national culture. GLOBE based their data on 825 organizations in 62 countries and they identify nine dimensions of national culture.
Hofstede dimension are power distance, individualism versus collectivism, masculinity versus femininity, uncertainty avoidance, and long-term versus short-term. Some of the GLOBE dimensions are power distance, individualism/collectivism, humane orientation, performance orientation, uncertainty avoidance, gender differentiation, and future orientation.
The two frameworks are very similar and are used to understand the differences of employees from other counties. These frameworks can also be helpful in predicting and explaining behavior of employees.
'While' is similar to 'Until', but like an opposite. 'Do While' will loop as long as something is within a certain range
Dim x As Integer = Console.Readline()
Do While x < 10
x = x + 1
Console.Writeline(x)
Next
Dim x As Integer = Console.Readline()
Do Until x >= 10
x = x + 1
Console.Writeline(x)
Next
What is the difference between throw and throws in net?
"throw" is the keyword to raise an exception. "throws" is a Java keyword that indicates a specific method can potentially raise a named exception. There is no analog in VB.Net or C#. Perhaps there is a "throws" keyword in J#?
What is the purpose of having ipEndPoint in .Net 2.0?
The purpose of having ipEndPoint in Net 2.0 is to represent a network endpoint as an IP address and a port number. By combining the host's IP address and port number of a service, the ipEndPoint class forms a connection point to a class.