Q5: Given two tables Student(SID, Name, Course) and Level(SID, level) write the
SQL statement to get the name and SID of the student who are taking course = 3 a
nd at freshman level.
Ans: SELECT Student.name, Student.SID
FROM Student, Level
WHERE Student.SID = Level.SID
AND Level.Level = "freshman"
AND Student.Course = 3;
Q7: Write the Java code to declare any constant (say gravitational constant) and
to get its value
Ans: Class ABC
{
static final float GRAVITATIONAL_CONSTANT = 9.8;
public void getConstant()
{
system.out.println("Gravitational_Constant: " + GRAVITATIONAL_CONSTANT);
}
}
Q3: Can you write Java code for declaration of multiple inheritance in Java ?
Ans: Class C extends A implements B
{
}
Q2: What is index table and why we use it? Index table are based on a sorted ord
ering of the values. Index table provides fast access time when searching.
Q3: In Java why we use exceptions? Java uses exceptions as a way of signaling se
rious problems when you execute a program. One major benefit of having an error
signaled by an exception is that it separates the code that deals with errors fr
om the code that is executed when things are moving along smoothly. Another posi
tive aspect of exceptions is that they provide a way of enforcing a response to
particular errors.
Q: Why would you want to have more than one catch block associated with a single
try block in Java?
A: Since there are many things can go wrong to a single executed statement, we s
hould have more than one catch(s) to catch any errors that might occur.
Q: What does the JSP engine do when presented with a JavaServer Page to process?
A: The JSP engine builds a servlet. The HTML portions of the JavaServer Page bec
ome Strings transmitted to print methods of a PrintWriter object. The JSP tag po
rtions result in calls to methods of the appropriate JavaBean class whose output
is translated into more calls to a println method to place the result in the HT
ML document.