Languages [Sahi Placement]: Sample Questions 1 - 2 of 7

Get unlimited access to the best preparation resource for competitive exams : get questions, notes, tests, video lectures and more- for all subjects of your exam.

Question 1

Languages
Edit

Write in Short

Short Answer▾

What are public, private, protected in JAVA? (2009/2010)

Explanation

Java provides a number of access modifiers to set access levels for classes, variables, methods and constructors. The four access levels are:

  • Visible to the package i.e.. default. No modifiers are needed.
  • Visible to the class only (private) .
  • Visible to the world (public) .
  • Visible to the package and all subclasses (protected) .

Question 2

Languages
Edit

Write in Short

Short Answer▾

What is the difference between interface and abstract class? (2009 - 10)

Explanation

Difference between an abstract class and Interface is given below.

This Table Give the Difference between Abstract and Interface
AbstractInterface
Abstract class can extend only one class or one abstract class at a timeInterface can extend any number of interfaces at a time
Abstract class can have both abstract and concrete methodsInterface can have only abstract methods
In abstract class keyword ‘abstract’ is mandatory to declare a method as an abstractIn an interface keyword ‘abstract’ is optional to declare a method as an abstract
Abstract class can have protected , public and public abstract methodsInterface can have only public abstract methods i.e.. by default
Abstract class can have static, final or static final variable with any access specifierInterface can have only static final (constant) variable i.e.. by default

Developed by: