Questions tagged [object]

An object is any entity that can be manipulated by commands in a programming language. An object can be a value, a variable, a function, or a complex data-structure. In object-oriented programming, an object refers to an instance of a class.

Objects in object-oriented programming (OOP) are data structures combined with the associated processing routines. Classes are sets of objects, while objects are instances of sets. Objects have members and methods, defining their properties and their abilities. Classes can have their own members and methods, which define the properties and abilities of the set of objects. For instance, if we have a Bird class, its objects might have an age property and a fly ability, while the Bird class might have a number of birds or a migrate ability, which is applicable for the set. Class-level methods are called static, or shared. For instance, a file could be represented as an object: a collection of data and the associated read and write routines. In typical object-oriented languages, all objects are instances of classes.

Properties of an object

Three properties characterize objects:

  • Identity: the property of an object that distinguishes it from other objects
  • State: describes the data stored in the object
  • Behavior: describes the methods in the object's interface by which the object can be used

See also:

  • (Used as a template for creating new objects)
  • (Object-oriented programming)

Resource

64898 questions
11
votes
3 answers

Why is every successful QueryInterface() call followed by Release() call?

Why is a QueryInterface() call always followed by a Release() call? For example, I have seen a sample code from MSDN as below: HRESULT hr = S_OK; CDecoder *pObj = new CDecoder(&hr); if (SUCCEEDED(hr)) { *ppv = NULL; hr =…
Arun Reddy Kandoor
  • 203
  • 1
  • 2
  • 10
11
votes
2 answers

Python, how to sort list of object?

I have a list of object that looks like this. hand = [ Card(10, 'H'), Card(2,'h'), Card(12,'h'), Card(13, 'h'), Card(14, 'h') ] Card(10, 'H) here is not a tuple, but an object. I know how to sort this list if each item in the list was in a form of…
Eric Kim
  • 2,493
  • 6
  • 33
  • 69
11
votes
1 answer

Object creation using class vs interface in Typescript (Angular 5 ) vs Java and C#

I want to understand using interface vs class to create model in angular 2. When we create model in Java or C#, we use model classes to represent data model that pass around in our application and therefore strongly typed. //C# public class Movie…
phonemyatt
  • 1,287
  • 17
  • 35
11
votes
3 answers

Flat array to multi dimensional array (JavaScript)

I have the following array: var sampleArray = [ "CONTAINER", "BODY", "NEWS", "TITLE"]; I want to have the following output: var desiredOutput = [{ "CONTAINER": [{ "BODY": [{ "NEWS": [{ …
andika23
  • 123
  • 7
11
votes
3 answers

Why isn't localStorage accepting my object?

I need to store an object like the one I the example below in localstorage. I need to be able to retrieve this object and edit it, then save it back into localStorage for next time. var data = {lastEdit:"September", expires:"December",…
Jamie W
  • 439
  • 3
  • 21
11
votes
1 answer

how type variable allowing wrong type?

package org.my.java; public class TestTypeVariable { static void typeVarType(T t, A a){ System.out.println(a.getClass()); System.out.println(t.getClass()); } public static void main(String[] s){ …
Atul
  • 521
  • 1
  • 7
  • 20
11
votes
3 answers

Angular4 copy object without reference?

Inside a component I tried to copy an object from a service that could be modified inside the component, but should stay in the service. private test; public ngOnInit(): { console.log(this.someService.test.someProperty) //'old' this.test =…
Max Solid
  • 1,213
  • 3
  • 21
  • 32
11
votes
2 answers

Access property value as string literal in PHP

Okay, im relearning php for a small home project and run into a problem so heres a quick one for all u php experts: I have build an abstract class which should access properties of YQL Yahoo returned JSON objects decoded to PHP objects. Lets say I…
Muleskinner
  • 14,150
  • 19
  • 58
  • 79
11
votes
5 answers

How can I safely retrieve this property of this object?

I have a Stripe subscription object that looks like this... subscription: { items: { data: [ plan: { id: 'my_plan_id' } ] } } What's the best way to safely retrieve the plan id?…
Henry
  • 564
  • 3
  • 22
11
votes
7 answers

Inheritance in java and Superclasses(Object, Class)

Is java.lang.Object superclass of all the custom class/objects inherited implicitly? I thought java didn't support multiple inheritance. The reason I ask is if I already inherit from another class in my custom class and again java is forcing…
Carbonizer
  • 1,915
  • 2
  • 19
  • 22
11
votes
5 answers

What is exactly an object in C++?

In the beginning of my journey learning C++, I thought an object is an OOP-only related term. However, the more I learn and the more I read, I can see that this not the case, and I can find that the term "object" has a more generalized meaning. I…
Kamal Zidan
  • 474
  • 2
  • 9
11
votes
2 answers

How do I set default values for instance variables?

In my assignment, I'm given a Food class like this: class Food { private String name; // name of food private int calPerServing; // calories per serving // must be >= 0 // min storage temperature // must be >= 0. // max storage…
Begüm Sakin
  • 141
  • 1
  • 1
  • 5
11
votes
5 answers

Multiple object properties assignment in Javascript

Is there some kind of shorthand for this? object.position.x = position.x object.position.y = position.y object.position.z = position.z object.rotation.x = rotation.x object.rotation.y = rotation.y object.rotation.z = rotation.z Thanks for your…
Damjan Pavlica
  • 31,277
  • 10
  • 71
  • 76
11
votes
4 answers

Compare two objects for properties with different values

I need to create a generic method, which will take two objects (of same type), and return list of properties which have different values. As my requirement is bit different I don't think this as duplicate. public class Person { public string Name…
Rahul
  • 2,431
  • 3
  • 35
  • 77
11
votes
2 answers

Creating not copyable, but movable, objects in c++

Just a question. Looking at C++ Boost libraries (in particular boost::thread class) I ended up thinking: "how is it possible to create a class defining objects that cannot be copied but that can be returned from a function?" Well consider this…
Andry
  • 493
  • 1
  • 5
  • 6
1 2 3
99
100