Sahi Papers: Sample Questions 1 - 2 of 7

Examrace Placement Series prepares you for the toughest placement exams to top companies.

Question number: 1

» Languages » Java

Short Answer Question▾

Write in Short

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 number: 2

» Languages » Java

Short Answer Question▾

Write in Short

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

Explanation

Difference between an abstract class and Interface is given below.

Difference between Abstract and Interface

This table give the difference between abstract and interface

Difference between Abstract and Interface

This table give the difference between abstract and interface

Difference between Abstract and Interface

This table give the difference between adstract and interface

Abstract

Interface

Abstract class can extend only one class or one abstract class at a time

Interface can extend any number of interfaces at a time

Abstract class can have both abstract and concrete methods

Interface can have only abstract methods

In abstract class keyword ‘abstract’ is mandatory to declare a method as an abstract

In an interface keyword ‘abstract’ is optional to declare a method as an abstract

Abstract class can have protected, public and public abstract methods

Interface can have only public abstract methods i. e. by default

Abstract class can have static, final or static final variable with any access specifier

Interface can have only static final (constant) variable i. e. by default

Sign In