0% found this document useful (0 votes)
42 views

Assignment #1 On Oops: Submitted By: Ashif Ikbal Anish MCA 2nd Sem ID: CS16MCAGN012 Kaziranga University 2017

This document contains a student's assignment submission for their OOP class. It includes responses to 5 questions: 1) Differences between OOP and POP in 3 paragraphs with 10 points. 2) Differences between C and C++ in 3 paragraphs with 11 points. 3) Differences between C and Java in 3 paragraphs with 7 points. 4) Differences between C++ and Java in 7 points. 5) Definition and explanation of PRAGMA in 2 paragraphs.

Uploaded by

Archana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
42 views

Assignment #1 On Oops: Submitted By: Ashif Ikbal Anish MCA 2nd Sem ID: CS16MCAGN012 Kaziranga University 2017

This document contains a student's assignment submission for their OOP class. It includes responses to 5 questions: 1) Differences between OOP and POP in 3 paragraphs with 10 points. 2) Differences between C and C++ in 3 paragraphs with 11 points. 3) Differences between C and Java in 3 paragraphs with 7 points. 4) Differences between C++ and Java in 7 points. 5) Definition and explanation of PRAGMA in 2 paragraphs.

Uploaded by

Archana
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 7

ASSIGNMENT #1

ON OOPS

Submitted By:
Ashif Ikbal Anish
MCA 2nd Sem
ID: CS16MCAGN012
KAZIRANGA
UNIVERSITY
2017
1. Differences between OOP and POP.

Ans: The basic differences between OOP and POP are explained below:
i. In POP, program is divided into small parts called functions whereas In OOP,
program is divided into parts called objects.

ii. In POP, Importance is not given to data but to functions as well as sequence of
actions to be done whereas In OOP, Importance is given to the data rather than
procedures or functions because it works as a real world.

iii. POP follows Top down approach whereas OOP follows Bottom up approach.

iv. POP does not have any access specifier but OOP has access specifiers named
Public, Private, Protected, etc.

v. In POP, Data can move freely from function to function in the system whereas In
OOP, objects can move and communicate with each other through member
functions.

vi. To add new data and function in POP is not so easy but OOP provides an easy way
to add new data and function.

vii. In POP, Most function uses Global data for sharing that can be accessed freely
from function to function in the system whereas In OOP, data cannot move easily
from function to function, it can be kept public or private so we can control the
access of data.

viii. POP does not have any proper way for hiding data so it is less secure but OOP
provides Data Hiding so provides more security.

ix. In POP, Overloading is not possible whereas In OOP, overloading is possible in the
form of Function Overloading and Operator Overloading.

x. Example of POP are: C, VB, FORTRAN, Pascal whereas Example of OOP are :
C++, JAVA, VB.NET, C#.NET.
2. Differences between C and C++

Ans: The differences between C and C++ are discussed below:

i. C was developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs
whereas C++ was developed by Bjarne Stroustrup in 1979 with C++'s predecessor
"C with Classes".

ii. When compared to C++, C is a subset of C++ whereas C++ is a superset of C. C++
can run most of C code while C cannot run C++ code.

iii. C supports procedural programming paradigm for code development whereas C++
supports both procedural and object oriented programming paradigms; therefore
C++ is also called a hybrid language.

iv. C does not support object oriented programming; therefore it has no support for
polymorphism, encapsulation, and inheritance but being an object oriented
programming language C++ supports polymorphism, encapsulation, and
inheritance.

v. In C (because it is a procedural programming language), data and functions are


separate and free entities but In C++ (when it is used as object oriented
programming language), data and functions are encapsulated together in form of an
object. For creating objects class provides a blueprint of structure of the object.

vi. In C, data are free entities and can be manipulated by outside code. This is because
C does not support information hiding whereas In C++, Encapsulation hides the
data to ensure that data structures and operators are used as intended.

vii. C, being a procedural programming, it is a function driven language, While, C++,


being an object oriented programming, it is an object driven language.

viii. C does not support function and operator overloading whereas C++ supports both
function and operator overloading.
ix. C does not allow functions to be defined inside structures but In C++, functions
can be used inside a structure.

x. C uses functions for input/output. For example scanf and printf whereas C++ uses
objects for input output. For example cin and cout.

xi. C provides malloc() and calloc() functions for dynamic memory allocation, and
free() for memory de-allocation but C++ provides new operator for memory
allocation and delete operator for memory de-allocation.

3. Differences between C and Java.


Ans: The major differences between C and Java are listed below:
i. 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.

ii. Java is an Interpreted language while C is a compiled language that means we all
know what a compiler does. It takes your code & translates it into something the
machine can understand-that is to say-0s & 1s-the machine-level code. Thats
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.

iii. 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 language (abstracted from the machine-level
details, closer significance to the program itself).

iv. 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.

v. 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.

vi. 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.

vii. The standard Input & Output Functions. Although this difference might not hold
any conceptual(intuitive) significance, but its 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.

4. Differences between C++ and Java.


Ans: The main differences between C++ and Java are discussed below.

i. Java does not support pointers, templates, unions, operator overloading, structures
etc.whereas C++ supports structures, unions, templates, operator overloading,
pointers and pointer arithmetic.

ii. Java is a pure object oriented programming language; therefore, everything is an


object in Java (single root hierarchy as everything gets derived from
java.lang.Object) On the contrary, in C++ there is no such root hierarchy. C++
supports both procedural and object oriented programming; therefore, it is called a
hybrid language.

iii. Java does not support conditional compilation and inclusion but Conditional
inclusion (#ifdef #ifndef type) is one of the main features of C++.

iv. There is no goto statement in Java. The keywords const and goto are reserved, even
though they are not used but C++ has goto statement. However, it is not considered
good practice to use of goto statement.

v. Java has method overloading, but no operator overloading. The String class does
use the + and += operators to concatenate strings and String expressions use
automatic type conversion, but that's a special built-in case but C++ supports both
method overloading and operator overloading.

vi. Java is interpreted for the most part and hence platform independent whereas C++
generates object code and the same code may not run on different platforms.

vii. Java has built-in support for documentation comments (/** ... */); therefore, Java
source files can contain their own documentation, which is read by a separate tool
usually javadoc and reformatted into HTML. This helps keeping documentation
maintained in easy way whereas C++ does not support documentation comments.
5. Define and Explain PRAGMA.

Ans: The #pragma directive is the method specified by the c standard for providing
additional information to the compiler beyond what is conveyed in the language
itself. The form of this directive specified by C standard are prefixed with STDCA
c compiler is free to attach any meaning it likes to other pragmas. All GNU
defined, supports pragma have been give a GCC prefix. C++ introduced the
pragma operator. This feature addresses a major problem with #pragma, being a
directive it cannot be produced as a result of macro expansion. Prama is an
operator much like size of or defined, and can be embedded in a macro. Its syntax
is pragma (string literal) where string literal can be either normal or wide character
string literal. It is represented by replacing all || with a single \ and all (\) with
a (). The result is then processed as if it had appeared as the right hand side of
#pragma directive.

You might also like