Color Coded Chips
This helps them identify the explosives.
Answer:
see explaination
Explanation:
public class Counter
{ int counter,limit;
static int nCounters = 0;
Counter(int a,int b)
{ counter=a; limit=b;
nCounters++;
}
void increment()
{ if(counter<limit)
counter++;
}
void decrement()
{ if(counter>0)
counter--;
}
private int getValue()
{ return counter;
}
private static int getNCounters()
{ return nCounters;
}
}
Answer:
Pros and cons of multiple inheritance
Pros
a) You categorize classes in many different ways. Multiple inheritance is a way of showing our natural tendency to organize the world. During analysis, for example, we use multiple inheritance to capture the way users classify objects.
b) By having multiple superclasses, your subclass has more opportunities to reuse the inherited attributes and operations of the superclasses.
Cons
a) If two classes have a method with the same name, the new subclass doesn't know which one to call.
b) multiple inheritance can lead to a lot of confusion when two base classes implement a method with the same name.
c) The more superclasses your subclass inherits from, the more maintenance you are likely to perform. If one of the superclasses happens to change, the subclass may have to change as well.
d) When a single subclass inherits the same attribute or operation from different superclasses, you must choose exactly which one it must use.
Explanation: Question 2
Some programming languages such as Java don’t allow you to use multiple inheritance. You must translate multiple inheritance into single inheritance or individual Java interfaces. This can be confusing and difficult to maintain because the implemented code for categorizing objects is quite different from the way the user organizes those objects. So, when the user changes their mind or adds another category, it is difficult to figure out how to program the new subclass.
Answer:
3e : 00111110 (62)
3e0 : 0000001111100000 (992)
3e00 : 0011111000000000 (15872)
Explanation:
Converting the given hexadecimal numbers to binary and decimal format:
1) 3e
3-> 0011
e-> 1110
Combining , 3e -> 00111110
This can be converted to decimal by multiplying each 1 in the binary representation by 2^(position -1) and adding the results.
So 3e = 32+16+8+4+2 = 62
2) 3e0
Binary => 0000001111100000
Converting to decimal : 992 [ This is 16 times a]
3) 3e00
Binary => 0011111000000000
Converting to decimal : 15872 [ This is 16 times b]
So adding a 0 to the hex representation multiplies the decimal number by 16.