Let s be a reference to an object of a given class, then *s returns a pointer to
ID: 3838888 • Letter: L
Question
Let s be a reference to an object of a given class, then *s returns a pointer to that object. When a class is derived from an already existing one, the derived class member functions may have names that are the same as the ones declared in the base class. The declaration static func () implies that func manipulates object-wide information. It is sometimes useful to specify a class from which no objects will ever be created A regular virtual function declared in a base class must be implemented in the same base class. In a base class, pure virtual functions may be implemented in that class. A destructor function of a base class can be declared virtual. A pure virtual function declared in the base class must be implemented in every class derived from the base one. A derived class always call the constructor of its base class before executing the body of its own constructor. A constructor function of a base class can be declared virtual A class that has a pure virtual member function is called a concrete base class. Is this a syntactically correct code? class B {public://... virtual void f () = 0;}; int main() {B b1, b2; If an exception is thrown inside a function, say, f(), but not handled there, the exception is propagated to the function that called f (). A function declared as follows: void func (parameter_list); must not throw any exception.. A function declared as follows: void func(parameter_list) throw (); must not throw any exception.Explanation / Answer
1. True - if s holds object reference(address) then *s returns pointer(content of the address which is the pointer to that object)
2. True - The derived class may have same function name as in the base class but when you are trying to access function derived class will get invoked.
Example:
package com;
public class Acc {
private double balance = 2.0;
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
}
package com;
public class newclass extends Acc{
private double balance = 1.0;
public double getBalance() {
return balance;
}
public static void main(String[] args) {
newclass n = new newclass();
System.out.println(n.getBalance());
}
}
3. True- if any function is static then it implies that func manipulates object-wide
example:
package com;
public class newclass {
private static double balance ;
public static double getBalance() {
return balance;
}
public static void main(String[] args) {
newclass n = new newclass();
n.setBalance(1.0);
newclass n2 = new newclass();
n.setBalance(2.0);
System.out.println(n.getBalance());
}
private void setBalance(double d) {
this.balance = d;
}
}
4. False: a class is not useful if no object is created for that class
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.