Vous êtes sur la page 1sur 9

A thread is similar to a separate process, in that it can do stuff (process) independently of other threads.

But it is lightweight, since the operating system doesn't have to give it its own memory space, since it shares memory with the other threads in the process. It is called light weight process to emphasize the fact that a thread is like a process but is more efficient and uses fewer resources( n hence "lighter")and they also share the address space. Why C is called as a Middle level Language? C is often called a middle-level computer language as it combines the elements of high-level languages with the functionalism of assembly language. High Level language : A high-level programming language is a programming language that is more user-friendly, to some extent platformindependent, and abstract from low-level computer processor operations such as memory accesses. Low Level Language : A low-level programming language is a programming language that is more machine specific, and from computer processor operations such as memory accesses is directly dependent.

or in simple i) it gives or behaves as High Level Language through Functions - gives a modular programming and breakup, increased efficiency for reusability (ii)it gives access to the low level memory through Pointers. Moreover it does support the Low Level programming i.e, Assembly Language. Answer - why C is Middle Level Language C Programming language is called as Middle Level Language because (i) it gives or behaves as High Level Language through Functions - gives a modular programming and breakup, increased efficiency for reusability (ii)it gives access to the low level memory through Pointers. Moreover it does support the Low Level programming i.e, Assembly Language. As its a combination of these two aspects, its neither a High Level nor a Low level language but a Middle Level Language. Cheers, Raghavan alias Saravanan M. Of note: C++ supports pointers and some basic assembly aspects. It is, however, high-level. C is 3rd generation, not due to pointers or functions, as most languages after the 1st generation include some implementation of these, but because it introduced the first (relatively speaking) aspects of object orientation (structs and enums). C++ carried on with this, leading to the "4th", which has become too varried to refer to as such. There is no such thing as a middle-level language. Machine code to BASIC to C to C++ and Java and such, C is definitively on the higher end of the programming specture.

Here are the major differences between C And JAVA. 1. JAVA is Object-Oriented while C is procedural. Different Paradigms, that is. Most differences between the features of the two languages arise due to the use of different programming paradigms. C breaks down to functions while JAVA breaks down to Objects. C is more procedure-oriented while JAVA is data-oriented.

2. Java is an Interpreted language while C is a compiled language. We all know what a compiler does. It takes your code & translates it into something the machine can understand-that is to say-0's & 1's-the machine-level code. That's exactly what happens with our C code-it gets 'compiled'. While with JAVA, the code is first transformed to what is called the bytecode. This bytecode is then executed by the JVM(Java Virtual Machine). For the same reason, JAVA code is more portable. 3. C is a low-level language while JAVA is a high-level language. C is a low-level language(difficult interpretation for the user, closer significance to the machine-level code) while JAVA is a high-level lagunage(abstracted from the machine-level details, closer significance to the program itself). 4. C uses the top-down {sharp & smooth} approach while JAVA uses the bottom-up {on the rocks} approach. In C, formulating the program begins by defining the whole and then splitting them into smaller elements. JAVA(and C++ and other OOP languages) follows the bottom-up approach where the smaller elements combine together to form the whole. 5. Pointer go backstage in JAVA while C requires explicit handling of pointers. When it comes to JAVA, we don't need the *'s & &'s to deal with pointers & their addressing. More formally, there is no pointer syntax required in JAVA. It does what it needs to do. While in JAVA, we do create references for objects. 6. The Behind-the-scenes Memory Management with JAVA & The User-Based Memory Management in C. Remember 'malloc' & 'free'? Those are the library calls used in C to allocate & free chunks of memory for specific data(specified using the keyword 'sizeof'). Hence in C, the memory is managed by the user while JAVA uses a garbage collector that deletes the objects that no longer have any references to them. 7. JAVA supports Method Overloading while C does not support overloading at all. JAVA supports function or method overloading-that is we can have two or more functions with the same name(with certain varying parameters like return types to allow the machine to differentiate between them). That it to say, we can overload methods with the same name having different method signatures. JAVA(unlike C++), does not support Operator Overloading while C does not allow overloading at all. 8. Unlike C, JAVA does not support Preprocessors, & does not really them. The preprocessor directives like #include & #define, etc are considered one of the most essential elements of C programming. However, there are no preprocessors in JAVA. JAVA uses other alternatives for the preprocessors. For instance, public static final is used instead of the #define preprocessor. Java maps class names to a directory and file structure instead of the #include used to include files in C. 9. The standard Input & Output Functions. Although this difference might not hold any conceptual(intuitive) significance, but it's maybe just the tradition. C uses the printf & scanf functions as its standard input & output while JAVA uses the System.out.print & System.in.read functions. 10. Exception Handling in JAVA And the errors & crashes in C. When an error occurs in a Java program it results in an exception being thrown. It can then be handled using various exception handling techniques. While in C, if there's an error, there IS an error. C++, as the name suggests is a superset of C. As a matter of fact, C++ can run most of C code while C cannot run C++ code. Here are the 10 major differences between C++ & C...

1. C follows the procedural programming paradigm while C++ is a multi-paradigm language(procedural as well as object oriented) In case of C, importance is given to the steps or procedure of the program while C++ focuses on the data rather than the process. Also, it is easier to implement/edit the code in case of C++ for the same reason. 2. In case of C, the data is not secured while the data is secured(hidden) in C++ This difference is due to specific OOP features like Data Hiding which are not present in C. 3. C is a low-level language while C++ is a middle-level language (Relatively, Please see the discussion at the end of the post) C is regarded as a low-level language(difficult interpretation & less user friendly) while C++ has features of both lowlevel(concentration on whats going on in the machine hardware) & high-level languages(concentration on the program itself) & hence is regarded as a middle-level language. 4. C uses the top-down approach while C++ uses the bottom-up approach In case of C, the program is formulated step by step, each step is processed into detail while in C++, the base elements are first formulated which then are linked together to give rise to larger systems. 5. C is function-driven while C++ is object-driven Functions are the building blocks of a C program while objects are building blocks of a C++ program.

6. C++ supports function overloading while C does not Overloading means two functions having the same name in the same program. This can be done only in C++ with the help of Polymorphism(an OOP feature) 7. We can use functions inside structures in C++ but not in C. In case of C++, functions can be used inside a structure while structures cannot contain functions in C. 8. The NAMESPACE feature in C++ is absent in case of C C++ uses NAMESPACE which avoid name collisions. For instance, two students enrolled in the same university cannot have the same roll number while two students in different universities might have the same roll number. The universities are two different namespace & hence contain the same roll number(identifier) but the same university(one namespace) cannot have two students with the same roll number(identifier) 9. The standard input & output functions differ in the two languages C uses scanf & printf while C++ uses cin>> & cout<< as their respective input & output functions 10. C++ allows the use of reference variables while C does not Reference variables allow two variable names to point to the same memory location. We cannot use these variables in C programming.

Similarities and Differences between c++ and java This list of similarities and differences is based heavily on The Java Language Environment, A White Paper by James Gosling and Henry McGilton http://java.sun.com/doc/language_environment/ and the soon-to-be published book, Thinking in Java by Bruce Eckel, http://www.EckelObjects.com/. At least these were the correct URLs at one point in time. Be aware, however, that the web is a dynamic environment and the URLs may change in the future. Java does not support typedefs, defines, or a preprocessor. Without a preprocessor, there are no provisions for including header files. Since Java does not have a preprocessor there is no concept of #define macros or manifest constants. However, the declaration of named constants is supported in Java through use of the final keyword. Java does not support enums but, as mentioned above, does support named constants. Java supports classes, but does not support structures or unions. All stand-alone C++ programs require a function named main and can have numerous other functions, including both standalone functions and functions, which are members of a class. There are no stand-alone functions in Java. Instead, there are only functions that are members of a class, usually called methods. Global functions and global data are not allowed in Java. All classes in Java ultimately inherit from the Object class. This is significantly different from C++ where it is possible to create inheritance trees that are completely unrelated to one another. All function or method definitions in Java are contained within the class definition. To a C++ programmer, they may look like inline function definitions, but they aren't. Java doesn't allow the programmer to request that a function be made inline, at least not directly. Both C++ and Java support class (static) methods or functions that can be called without the requirement to instantiate an object of the class. The interface keyword in Java is used to create the equivalence of an abstract base class containing only method declarations and constants. No variable data members or method definitions are allowed. (True abstract base classes can also be created in Java.) The interface concept is not supported by C++. Java does not support multiple inheritance. To some extent, the interface feature provides the desirable features of multiple inheritance to a Java program without some of the underlying problems. While Java does not support multiple inheritance, single inheritance in Java is similar to C++, but the manner in which you implement inheritance differs significantly, especially with respect to the use of constructors in the inheritance chain. In addition to the access specifiers applied to individual members of a class, C++ allows you to provide an additional access specifier when inheriting from a class. This latter concept is not supported by Java. Java does not support the goto statement (but goto is a reserved word). However, it does support labeled break and continue statements, a feature not supported by C++. In certain restricted situations, labeled break and continue statements can be used where a goto statement might otherwise be used. Java does not support operator overloading. Java does not support automatic type conversions (except where guaranteed safe). Unlike C++, Java has a String type, and objects of this type are immutable (cannot be modified). Quoted strings are automatically converted into String objects. Java also has a StringBuffer type. Objects of this type can be modified, and a variety of string manipulation methods are provided.

Unlike C++, Java provides true arrays as first-class objects. There is a length member, which tells you how big the array is. An exception is thrown if you attempt to access an array out of bounds. All arrays are instantiated in dynamic memory and assignment of one array to another is allowed. However, when you make such an assignment, you simply have two references to the same array. Changing the value of an element in the array using one of the references changes the value insofar as both references are concerned. Unlike C++, having two "pointers" or references to the same object in dynamic memory is not necessarily a problem (but it can result in somewhat confusing results). In Java, dynamic memory is reclaimed automatically, but is not reclaimed until all references to that memory become NULL or cease to exist. Therefore, unlike in C++, the allocated dynamic memory cannot become invalid for as long as it is being referenced by any reference variable. Java does not support pointers (at least it does not allow you to modify the address contained in a pointer or to perform pointer arithmetic). Much of the need for pointers was eliminated by providing types for arrays and strings. For example, the oft-used C++ declaration char* ptr needed to point to the first character in a C++ null-terminated "string" is not required in Java, because a string is a true object in Java. A class definition in Java looks similar to a class definition in C++, but there is no closing semicolon. Also forward reference declarations that are sometimes required in C++ are not required in Java. The scope resolution operator (::) required in C++ is not used in Java. The dot is used to construct all fully-qualified references. Also, since there are no pointers, the pointer operator (->) used in C++ is not required in Java. In C++, static data members and functions are called using the name of the class and the name of the static member connected by the scope resolution operator. In Java, the dot is used for this purpose. Like C++, Java has primitive types such as int, float, etc. Unlike C++, the size of each primitive type is the same regardless of the platform. There is no unsigned integer type in Java. Type checking and type requirements are much tighter in Java than in C++. Unlike C++, Java provides a true boolean type. Conditional expressions in Java must evaluate to boolean rather than to integer, as is the case in C++. Statements such as if(x+y)... are not allowed in Java because the conditional expression doesn't evaluate to a boolean. The char type in C++ is an 8-bit type that maps to the ASCII (or extended ASCII) character set. The char type in Java is a 16-bit type and uses the Unicode character set (the Unicode values from 0 through 127 match the ASCII character set). For information on the Unicode character set see http://www.stonehand.com/unicode.html. Unlike C++, the >> operator in Java is a "signed" right bit shift, inserting the sign bit into the vacated bit position. Java adds an operator that inserts zeros into the vacated bit positions. C++ allows the instantiation of variables or objects of all types either at compile time in static memory or at run time using dynamic memory. However, Java requires all variables of primitive types to be instantiated at compile time, and requires all objects to be instantiated in dynamic memory at runtime. Wrapper classes are provided for all primitive types except byte and short to allow them to be instantiated as objects in dynamic memory at runtime if needed. C++ requires that classes and functions be declared before they are used. This is not necessary in Java. The "namespace" issues prevalent in C++ are handled in Java by including everything in a class, and collecting classes into packages. C++ requires that you re-declare static data members outside the class. This is not required in Java. In C++, unless you specifically initialize variables of primitive types, they will contain garbage. Although local variables of primitive types can be initialized in the declaration, primitive data members of a class cannot be initialized in the class definition in C++.

In Java, you can initialize primitive data members in the class definition. You can also initialize them in the constructor. If you fail to initialize them, they will be initialized to zero (or equivalent) automatically. Like C++, Java supports constructors that may be overloaded. As in C++, if you fail to provide a constructor, a default constructor will be provided for you. If you provide a constructor, the default constructor is not provided automatically. All objects in Java are passed by reference, eliminating the need for the copy constructor used in C++. (In reality, all parameters are passed by value in Java. However, passing a copy of a reference variable makes it possible for code in the receiving method to access the object referred to by the variable, and possibly to modify the contents of that object. However, code in the receiving method cannot cause the original reference variable to refer to a different object.) There are no destructors in Java. Unused memory is returned to the operating system by way of a garbage collector, which runs in a different thread from the main program. This leads to a whole host of subtle and extremely important differences between Java and C++. Like C++, Java allows you to overload functions. However, default arguments are not supported by Java. Unlike C++, Java does not support templates. Thus, there are no generic functions or classes. Unlike C++, several "data structure" classes are contained in the "standard" version of Java. More specifically, they are contained in the standard class library that is distributed with the Java Development Kit (JDK). For example, the standard version of Java provides the containers Vector and Hashtable that can be used to contain any object through recognition that any object is an object of type Object. However, to use these containers, you must perform the appropriate upcasting and downcasting, which may lead to efficiency problems. Multithreading is a standard feature of the Java language. Although Java uses the same keywords as C++ for access control: private, public, and protected, the interpretation of these keywords is significantly different between Java and C++. There is no virtual keyword in Java. All non-static methods always use dynamic binding, so the virtual keyword isn't needed for the same purpose that it is used in C++. Java provides the final keyword that can be used to specify that a method cannot be overridden and that it can be statically bound. (The compiler may elect to make it inline in this case.) The detailed implementation of the exception handling system in Java is significantly different from that in C++. Unlike C++, Java does not support operator overloading. However, the (+) and (+=) operators are automatically overloaded to concatenate strings, and to convert other types to string in the process. As in C++, Java applications can call functions written in another language. This is commonly referred to as native methods. However, applets cannot call native methods. Unlike C++, Java has built-in support for program documentation. Specially written comments can be automatically stripped out using a separate program named javadoc to produce program documentation. Generally Java is more robust than C++ due to the following:

y y y y

Object handles (references) are automatically initialized to null. Handles are checked before accessing, and exceptions are thrown in the event of problems. You cannot access an array out of bounds. Memory leaks are prevented by automatic garbage collection.

C Array length example

y y y
In this section you will learn how to determine the length of an array in C. An array is a contiguous group of data items with the same name and data type. In order to get the length of an array, we have used the sizeof operator. The sizeof operator gives the amount of storage, in bytes, required to store an object. This operator avoids machine-dependent data sizes in the programs. #include- Coded statements that contain (#)sharp sign are are the directives of the preprocessor. In our example #include<stdio.h> is an indication for preprocessor of the compiler and it means to include the stdio.h header file. <stdio.h>- This is the header file due to which standard input/output functions are included to be performed into the program. It is necessary to include this header file as it is having some inbuilt functions like printf(), scanf() etc. The angle brackets are used to indicate system include files. <conio.h>- Its a non standard header file that contains clrscr(), getch() functions. void main() - main is the function, inside which the compiler looks for the data to compile first. Though this method has default return int but the return type can be set to void that means now method return type is void and it will return no value. clrscr()- It is used to clear the console screen. sizeof(array)/sizeof(int)- These are the operators that determines the length of the array passed inside the operator parentheses.. getch()- This function reads each character. It holds the console screen and program output on it. Without this output on the screen will generate in flash and vanishes. Here is the code: ARRAYLEN.C #include <stdio.h> #include <conio.h> int array[6]= { 1, 2, 3, 4, 5, 6 }; void main() { clrscr(); int len=sizeof(array)/sizeof(int); printf("Length Of Array=%d", len); getch(); }

y y

y y

What is the difference between Strings and Arrays? Answer A data item (or variable) is described as a "string" type when it contains some number of characters. Those characters can usually be anything in the system's accepted list of codes. Most systems use ASCII, so a string can include the letters a-z, AZ, numbers 0-9, and special characters like ~!@#$%^&*()_+-=[]\{}|:";'<>?,/. A string is treated as a single object, although most programming languages have methods to break strings apart (called sub-stringing). In the Perl language, strings are named $something. An array is a collection of individual data items, sort of like a list. Each element in an array can be referred to in a program by its position in the list. In the Perl language, an array would be named @SOMETHING. The first element in the array would be named $SOMETHING[0], the second $SOMETHING[1], and so on. Each element can be a string, or some other data type. Other data types would be intergers (positive or negative whole numbers), floating point (decimal numbers like 3.14159 or 2398.41; it can be more complicated than this, but that's another story), and a few more exotic types. Answer: In the C programming language a string is actually the same as an array of characters. The last character in a C string is a zero byte which indicates the end of the string.

What is the Difference between DBMS and RDBMS?

A DBMS has to be persistent, that is it should be accessible when the program created the data ceases to exist or even the application that created the data restarted. A DBMS also has to provide some uniform methods independent of a specific application for accessing the information that is stored. RDBMS is a Relational Data Base Management System Relational DBMS. This adds the additional condition that the system supports a tabular structure for the data, with enforced relationships between the tables. This excludes the databases that don't support a tabular structure or don't enforce relationships between tables. Many DBA's think that RDBMS is a Client Server Database system but thats not the case with RDBMS. Yes you can say DBMS does not impose any constraints or security with regard to data manipulation it is user or the programmer responsibility to ensure the ACID PROPERTY of the database whereas the rdbms is more with this regard bcz rdbms define the integrity constraint for the purpose of holding ACID PROPERTY. I have found many answers on many websites saying that DBMS are for smaller organizations with small amount of data, where security of the data is not of major concern and RDBMS are designed to take care of large amounts of data and also the security of this data. and this is completely wrong by definition of RDBMS and DBMS

Determining the largest number

This example of Java programming will teach you the coding for determining the largest number amongst three. Here we have taken three integers as x = 500, y = 70 and z = 3000. After defining these three integers under the class "largernumber" apply "if" and "else" conditions that can help you in finding the largest value one by one. First check if "x>y". If this satisfies then check whether x>z or not. Again if this satisfies then write in the system class that "x is greater". Again the term "else" comes when "x" is not greater than "z". So check again, if "z" is greater than "y" or not. If this satisfies then type in the system class as "z is greater" otherwise (in the else condition) "y" is greater. Now check whether "y" is greater than "z" or not. If "x" is not greater than "y" as per the first condition, then the condition "else" comes and now you have to check if "y>z" or not. If this satisfies then the output comes as "y is greater". Don't get confuse and analyze every condition one by one and follow this example. Here is the code of program: class largernumber{ public static void main(String[] args) { int x=500, y=70, z=3000; if (x>y){ if (x>z){ System.out.println("x is greater"); } else{ if(z>y){ System.out.println("z is greater"); } else{ System.out.println("y is greater"); } } }

else{ if (y>z){ System.out.println("y is greater"); } } } }

y y y y y y y y y y y y y y y y y y y y y y y y y y

public class JavaFibonacciSeriesExample { public static void main(String[] args) { //number of elements to generate in a series int limit = 20; long[] series = new long[limit]; //create first 2 series elements series[0] = 0; series[1] = 1; //create the Fibonacci series and store it in an array for(int i=2; i < limit; i++){ series[i] = series[i-1] + series[i-2]; } //print the Fibonacci series numbers System.out.println("Fibonacci Series upto " + limit); for(int i=0; i< limit; i++){ System.out.print(series[i] + " "); } } }

Vous aimerez peut-être aussi