Java Programming OOPs
Questions 271 to 280
271.
|
Select
from among the following what Java can do?
|
||||||||||
272.
|
In
addition to JDK there are a number of Java commercial development tools
available for Java programmers. Select from among the following such Java
commercial development tool available.
|
||||||||||
273.
|
Which is
identified as the first ever Object Oriented Programming Language?
|
||||||||||
274.
|
How
comments that can be used in Automatic Class Documentation by javadoc
tool are represented?
|
||||||||||
275.
|
Which
one of the following is legal valid variable name among the following?
Suppose we create the following
classes Account and OverdraftAccount to represent bank accounts. An Overdraft
Account is a subtype of a general Account.
/**
Account represents a mutable bank account. **/
class Account
{
double balance;
/**
@effects constructs a new Account with
*
balance = initialBalance */
Account(double initialBalance) {
this.balance
= initialBalance;
}
/**
Returns a textual description of the type of this account.
*
@return the String "Account" */
String
getAccountType() {
return "Account";
}
/**
@effects prints to standard output the type of this account
*
followed by the balance. */
void printBalance()
{
System.out.println(this.getAccountType() + ":
$" + balance);
}
}
/**
OverdraftAccount represents a mutable bank account with a credit limit.*/
class OverdraftAccount
extends Account {
double creditLimit;
/**
@effects constructs a new OverdraftAccount with
*
balance = initialBalance,
*
creditLimit = initialCreditLimit */
OverdraftAccount(double initialBalance, double initialCreditLimit) {
super(initialBalance);
this.creditLimit
= initialCreditLimit;
}
/**
Returns a textual description of the type of this account.
*
@return the String "OverdraftAccount" */
String
getAccountType() {
return "OverdraftAccount";
}
}
|
||||||||||
276.
|
The
method getAccountType() is invoked in the code for printBalance().
What is
the compile-time type of the receiver of this method invocation?
|
||||||||||
277.
|
Suppose
we now wish to print the balance information for an account with the
following code:
Account myAccount = new OverdraftAccount(5, 10);
myAccount.printBalance();
Which of
the following statement is true?
|
||||||||||
278.
|
Given the code below:
class
A {
public
void print() { System.out.println("hi"); }
}
class
B extends A {
public
void print() { System.out.println("bye"); }
}
What
does each of the following code samples do:
A a = new B();
a.print();
|
||||||||||
279.
|
Given
the code below:
class
A {
public void print() {
System.out.println("hi"); }
}
class
B extends A {
public void print() {
System.out.println("bye"); }
}
B
b = new A();
b.print();
|
||||||||||
280.
|
What is the size of the Short
integer type in terms of bits?
|
Answers
271.
|
Answer : (e)
Reason: With Java Object oriented
applications , Networking applications, database applications, can be
developed.
|
272.
|
Answer : (a)
Reason: Borland Jbuilder is the right choice as the other are for
different purposes.
|
273.
|
Answer : (d)
Reason: Simula67 is the first ever object oriented programming language.
|
274.
|
Answer : (c)
Reason: Remaining are for single line and multiline comments
|
275.
|
Answer : (d)
Reason: variable names should only
Start with a Letter, Underscore (_) , or Dollar Sign ($).After the first
letter Name can include any letter or Number but cannot include Symbols such
as %, @, * and so on.
|
276.
|
Answer : (b)
Reason: T he receiver of the method invocation is implicitly
"this", which, in the context of the Account class in which the
printBalance() resides, has a compile-type of Account. Note that an object
has only one compile-time type; thus, circling both Object and Account is
incorrect, even though Account is a subtype of Object.
|
277.
|
Answer : (d)
Reason: OverdraftAccont.getAccountType() is called
from printBalance() as myAccount has a runtime type of OverdraftAccount.
|
278.
|
Answer : (c)
Reason: T he print() method of the run-time type, B,
is called.
|
279.
|
Answer : (d)
Reason: The compiler will not allow you to set an object reference to an
instance whose runtime type is a Java supertype of the variable's compile
time type.
|
280.
|
Answer : (b)
Reason: Short integer in 16 bits or 2 bytes
|
thank you.
ReplyDeletejava tutorial
java tutorial