In C++, we use pointer. While, In java, we do not use pointer ; But both are "Object Oriented Programming", then why is it so? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
+ 5

In C++, we use pointer. While, In java, we do not use pointer ; But both are "Object Oriented Programming", then why is it so?

Memory leak from variables

28th Nov 2018, 2:51 PM
Bipin Tatkare
Bipin Tatkare - avatar
12 Answers
+ 8
Usage of pointers has nothing to do with OOP; it is a memory management resource. A language is OOP if it is focused on programming using classes, and those classes may or may not contain pointers.
28th Nov 2018, 3:22 PM
Bebida Roja
Bebida Roja - avatar
+ 5
You're comparing apples and oranges. C++ allow you to access low-level components of software and hardware. Java, on the otherhand, is a language for internet. Two entirely different concept
29th Nov 2018, 8:30 AM
Da2
Da2 - avatar
+ 3
Firstly, using pointers or not has nothing to do with object oriented programming. C++ isn't object oriented. It supports object oriented programming. Its just one of the programming paradigms that C++ supports (just like it supports functional programming, generic programming, etc...). Java, the language itself, is based on C++ and yes, programmers don't have access to pointers in it but Java IS using pointers. Infact, every object you create in java is a pointer by default. It shouldn't be very surprising since it's based on C++. You just can't change it like you can do it in C++. That's why
29th Nov 2018, 7:46 PM
Shadowa
Shadowa - avatar
+ 2
But C++ is general purpose object oriented programming language. And java also an object oriented. In C++, we can make classes as well as objects, while in java also it is happened. But like smart pointer, java dosent support this! Why?
28th Nov 2018, 4:27 PM
Bipin Tatkare
Bipin Tatkare - avatar
+ 2
what is a object : a class c++ have classes java has classes c++ is oop java is oop
29th Nov 2018, 10:41 AM
iraj mohtasham
iraj mohtasham - avatar
+ 2
Iraj, in short, it's a data structure....
29th Nov 2018, 10:51 AM
Da2
Da2 - avatar
+ 2
A class is a layer of data structure. Object Oriented Programming is a a way of programming. Class - apple, Oop - orange, two entirely different concepts.. 😨
29th Nov 2018, 10:55 AM
Da2
Da2 - avatar
+ 2
A pointer is a C++ variable that contains the address of another variable in the computer's internal memory. ... For most computers, including Macintoshes and PCs, the smallest addressable piece of memory is a byte. A byte is 8 bits and corresponds to a variable of type char. What's a Pointer in C++? - dummies https://www.dummies.com › cpp › whats...
1st Dec 2018, 8:20 AM
Da2
Da2 - avatar
+ 1
c++ actually isnt object oriented. both languages are designed for different purposes. c++ is an old native language without any fancy features for developing directly on hardware. they just dont have heap/stack management or whatever. java is always running on an virtual machine and was designed with convinience and development speed over performance. short anwer: by design and purpose of both languages.
28th Nov 2018, 3:28 PM
Uglycut
Uglycut - avatar
+ 1
javas runtime environment ist managing all memory stuff. c++ doesnt have that, so you need to do it yourself. better answer ^^
28th Nov 2018, 4:04 PM
Uglycut
Uglycut - avatar
+ 1
because java isnt a native language. its running on a virtuall machine, there is no actual hardware you can point to. all memory management is handled by the runtime
28th Nov 2018, 4:40 PM
Uglycut
Uglycut - avatar
+ 1
Java is not a purely object oriented programming language as it supports primitive datatypes. Every object is pointer to itself that dynamically allocates memory to its class data members, class membered functions .
1st Dec 2018, 2:43 AM
Kondeti Sowjanya
Kondeti Sowjanya - avatar