oop Questions
10
Solved
What are the best practices for modeling inheritance in databases?
What are the trade-offs (e.g. queriability)?
(I'm most interested in SQL Server and .NET, but I also want to understand how othe...
Submultiple asked 10/10, 2008 at 6:3
2
Solved
I would like to model a database entity for a set of players.
Each player should have :
a number of fixed fields (name, role, ...)
a number of variable fields for skill levels (if role is ATK, ...
Uriia asked 15/11, 2016 at 10:41
7
Solved
I am returning a json_encode() of an array of objects pulled from an ORM. It includes lots of properties with a null value. What is the neatest way to remove these properties that are null? I guess...
9
Solved
I had an interview days ago and was thrown a question like this.
Q: Reverse a linked list. Following code is given:
public class ReverseList {
interface NodeList {
int getItem();
NodeList nex...
2
Do I always need to instantiate the parent class as well for this example because it still works when I remove it?
class Person:
def __init__(self, name):
self.name = name
@property
def name(...
Ostracize asked 3/10, 2020 at 1:1
11
Solved
Can an interface be declared as final in Java?
9
Solved
I have two classes that refer to each other, but obviously the compiler complains. Is there any way around this?
EDIT
Actually my code is slightly different than what Hank Gay uses. So python can...
6
Solved
What is the difference between using self and static in the example below?
class Foo
{
protected static $bar = 1234;
public static function instance()
{
echo self::$bar;
echo "\n";
echo sta...
13
Solved
A friend and I had an argument last week. He stated there were no such things as classes in JavaScript.
I said there was as you can say var object = new Object()
He says "as there is no word c...
Briarroot asked 2/5, 2010 at 8:37
5
Solved
I'm currently enjoying the transition from an object oriented language to a functional language. It's a breath of fresh air, and I'm finding myself much more productive than before.
However - ther...
Oaten asked 11/2, 2011 at 13:34
6
Solved
My first question: What is the difference between an protected and a public constructor in an abstract class?
My second questions: Does it make sense, if the abstract class has an private construc...
7
Solved
Is there a reason to use a 100% abstract class and not an interface ?
Can you give me a good example when to use both so I can grasp the concept a little?
Update:
100% Abstract class -> abstract c...
7
Solved
I know there was a some questions related to this, but there are in c++ or other languages. I get this error and I'm not sure what is wrong with my function.
My error looks like this:
Fatal erro...
5
It has been repeatedly said that the instanceof operator should not be used except in the equals() method, otherwise it's a bad OOP design.
Some wrote that this is a heavy operation, but it seems t...
Dougald asked 14/12, 2013 at 23:46
7
Solved
In Java, to reverse elements in a List, I need to use:
Collections.reverse(list)
I was just wondering why Java doesn't implement the reverse method within the List interface so that I could do t...
18
Is it possible to simulate abstract base class in JavaScript? What is the most elegant way to do it?
Say, I want to do something like:
var cat = new Animal('cat');
var dog = new Animal('dog');
cat...
Benediction asked 28/2, 2009 at 9:6
3
Solved
I wish to extend Python socket.socket with a new attribute (in particular, a queue.Queue, but could be anything else). I am trying
to decide whether I should use inheritance or composition, but at ...
Happen asked 20/7, 2017 at 6:58
10
What is the difference between a mixin and inheritance?
Biedermeier asked 13/5, 2009 at 20:31
2
Solved
I realize that it's possible to define a static class method as private and protected in PHP. This allows for an instantiated class, or public static method to access it's own private/protected sta...
20
Solved
Interviewer: What is encapsulation and how do you achieve it in Java?
Me: Encapsulation is a mechanism to hide information from the client. The information may be data or implementation or alg...
Adorn asked 17/8, 2012 at 21:31
2
Solved
I'm not able to get a constant from a class which is defined by using a string variable and PHP 5.3. namespaces. Example:
use \Some\Foo\Bar;
$class = 'Bar';
echo $class::LOCATION;
where LOCATIO...
Shocker asked 5/10, 2011 at 14:51
3
Solved
I have this code which calculates the distance between two coordinates. The two functions are both within the same class.
However, how do I call the function distToPoint in the function isNear?
cla...
International asked 11/4, 2011 at 0:20
8
Is it possible to create an object for an interface? If yes, how is it done?
According to my view the following code says that we can:
Runnable r = new Runnable() {
// some implementation
}
4
I don't understand the documentation:
Package-Level Functions
All the functions and properties declared in a file example.kt inside
a package org.foo.bar, including extension functions, are ...
Technics asked 5/11, 2017 at 0:27
1
When using doxygen to generate C++ inheritance diagrams, I've noticed that the diagrams can be incomplete.
If several projects are documented using tag files to allow cross-referencing, doxygen wi...
Cubital asked 8/9, 2016 at 22:26
© 2022 - 2024 — McMap. All rights reserved.