Write a block in PL/SQL to print the specific number of rows from a table.
Write a program in PL/SQL to print the value of a variable inside and outside a loop using LOOPEXIT statement.
Write a program in PL/SQL to show the uses of nested loop.
Write a Java method to compute the future investment value at a given interest rate for a
specified number of years.
Input the investment amount: 1000
Input the rate of interest: 10
Input number of years: 5
Years FutureValue
1 1104.71
2 1220.39
3 1348.18
4 1489.35
5 1645.31
When a subclass inherits from a superclass, it also inherits its methods; however, it can
also override the superclass methods (as well as declare and implement new ones). Consider the following Sports class:
class Sports{
String getName(){
return "Generic Sports";
}
void getNumberOfTeamMembers(){
System.out.println( "Each team has n players in " + getName() );
}
}
Next, we create a Soccer class that inherits from the Sports class. We can override the getName method and return a different, subclass-specific string:
class Soccer extends Sports{
@Override
String getName(){
return "Soccer Class";
}
}
Note: When overriding a method, you should precede it with the @Override annotation. The parameter(s) and return type of an overridden method must be exactly the same as those of the method inherited from the supertype.
Finish the Teacher constructor. Use super to use the Person constructor to set the fields
inherited from Person. It should print “Destini 20” followed by “Erica 55 Masters in Teaching”.
public class Person
{
private String name;
private int age;
public Person(String name, int age)
{
this.name = name;
this.age = age;
}
public String getName() { return this.name; }
public int getAge() { return this.age; }
public String toString()
{
return getName() + " " + getAge();
}
public static void main(String[] args)
{
Person p = new Person("Destini", 20);
System.out.println(p);
Teacher p2 = new Teacher("Erica", 55, "Masters in Teaching");
System.out.println(p2);
}
}
class Teacher extends Person
{
String degree;
public String getDegree() { return this.degree; }
public String toString()
{
return getName() + " " + getAge() + " " + getDegree();
}
public Teacher(String name, int age, String theDegree)
{
Charles wants to buy a nuckles in which
A stationary store uses a system to generate the customer purchase amount. The cashier needs to key in the item code and item quantity. Then, the system calculates the purchase amount and generate a receipt for the customer. Information on item code, item name, item description, item quantity, item price and purchase amount will be printed on the receipt.
A Java interface can only contain method signatures and fields. The interface can be used
to achieve polymorphism. In this problem, you will practice your knowledge on interfaces.
You are given an interface AdvancedArithmetic which contains a method signature int divisor_sum(int n). You need to write a class called MyCalculator which implements the interface.
divisorSum method just takes an integer as input and return the sum of all its divisors. For example divisors of 6 are 1, 2, 3 and 6, so divisor_sum should return 12. The value of n will be at most 1000.
Which database object is viewed by print preview