Tutor profile: Carrelpatrick G.
Questions
Subject: Python Programming
Can you name and explain some magic methods or dunder methods in Python?
1) __new__() method is one of the magic methods in 'Python'. Before the invocation of the '__init__()' method, the __new__() method is first called. 2) __str__() method is another useful magic method, which allows a programmer to return the string representation of an object.
Subject: Java Programming
Can we have multiple values mapped to a particular key? Justify your answer with an appropriate example.
Yes, definitely a key can be mapped to a set of values, using the 'Map' interface. Consider a scenario where the key is a 'string' and the associated set of values are also 'strings'. In such a case, you can create the mapping object in the following format. Map.entry<String,List<String>>entry = HashMap<String,List<String>>(); Now the map 'entry' has the key set to a 'String' and an associated set of values which are also strings.
Subject: C Programming
How would you read the following pointer? void (*ptr)(float (*)[5],int (*)(void))
The above statement can be decoded as - 'ptr' is a void pointer to a function, which takes two arguments. The first parameter is a - float pointer which points to a single-dimensional floating array with 5 cells. And the second parameter is a pointer to a function whose parameter is 'void'.
Contact tutor
needs and CarrelPatrick will reply soon.