Computer Applications
State whether the following statement is True or False :
A target does not have access to the private members of base class.
Encapsulation & Inheritance in Java
15 Likes
Answer
True
Answered By
2 Likes
Related Questions
State whether the following statement is True or False :
Visibility modes decide the access provided to the members from the target.
State whether the following statement is True or False :
Constructors of base and derived classes are automatically invoked while creating the objects of derived class.
State whether the following statement is True or False :
A single target inheriting many bases is known as multilevel inheritance.
A number is said to be Armstrong if the sum of cube of its digits is equal to the same number.
For example,
153 = 13 + 53 + 33
Hence, 153 is an Armstrong number.A program using a class is designed below to check and display whether a number 'num' is an Armstrong number or not. There are some places in the program left blank marked with ?1?, ?2?, ?3? and ?4? to be filled with suitable condition/expression.
class Armstrong { private int num; Armstrong(int n) { num = n; boolean check( ) { int nm = num; while(...?1?...) { digit = nm % 10; sum = sum + ...?2?... ; nm = ...?3?... ; } if (sum == num) return(true); else return(false); } void display( ) { boolean ch = check( ); if(ch == ...?4?... ) System.out.println("Number is Armstrong"); else System.out.println("Number is not Armstrong"); } } }Based on the above discussion, answer the following questions:
(a) What will be filled in place of ?1?
(b) What will be filled in place of ?2?
(c) What will be filled in place of ?3?
(d) What will be filled in place of ?4?