Home Java Technology Java Basics Java Questions - 6

Login Form




Java Questions - 6 Print E-mail

1. What is casting?

Conversion of one type of data to another when appropriate. Casting makes explicitly converting of data.

 

2. What are the disadvantages of using threads?

DeadLock.

 

3. What are the three types of priority?

MAX_PRIORITY which is 10, MIN_PRIORITY which is 1, NORM_PRIORITY which is 5.

 

4. What is polymorphism? Explain with an example.

In object-oriented programming, polymorphism refers to a programming language’s ability to process objects differently depending on their data type or class. More specifically, it is the ability to redefine methods for derived classes. For example, given a base class shape, polymorphism enables the programmer to define different area methods for any number of derived classes, such as circles, rectangles and triangles. No matter what shape an object is, applying the area method to it will return the correct results. Polymorphism is considered to be a requirement of any true object-oriented programming language

 

5. What is a class?

A class is a blueprint, or prototype, that defines the variables and the methods common to all objects of a certain kind.

 

6. What are the different types of modifiers?

There are access modifiers and there are other identifiers. Access modifiers are public, protected and private. Other are final and static.

 

7. 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 and at freshman level.

SELECT Student.name, Student.SID
FROM Student, Level
WHERE Student.SID = Level.SID
AND Level.Level = "freshman"
AND Student.Course = 3;

 

8. What is encapsulation? Explain with an example.

Encapsulation is the term given to the process of hiding the implementation details of the object. Once an object is encapsulated, its implementation details are not immediately accessible any more. Instead they are packaged and are only indirectly accessible via the interface of the object.

 

9. What is interface?

Interface is a contact that can be implemented by a class, it has method that need implementation.

 

10. What is a method?

Encapsulation of a functionality which can be called to perform specific tasks.