[go: up one dir, main page]

0% found this document useful (0 votes)
24 views3 pages

cs8392 Oops CT1

The document discusses various Java concepts like classes, access specifiers, constructors, packages, inheritance, interfaces, abstract classes and API packages. It defines each concept and provides examples. Classes are used to create objects, access specifiers control access to members, constructors initialize objects, packages organize related classes and interfaces provide flexible abstraction.

Uploaded by

elambaridhis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views3 pages

cs8392 Oops CT1

The document discusses various Java concepts like classes, access specifiers, constructors, packages, inheritance, interfaces, abstract classes and API packages. It defines each concept and provides examples. Classes are used to create objects, access specifiers control access to members, constructors initialize objects, packages organize related classes and interfaces provide flexible abstraction.

Uploaded by

elambaridhis
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

1.

Define classes in java


A class is a user defined blueprint or prototype from which objects are created. It represents
the set of properties or methods that are common to all objects of one type.
2. Define access specifier? give example
These Specifiers determine whether a field or method in a class, can be used or invoked by
another method in another class or sub-class
Types Of Access Specifiers :
In java we have four Access Specifiers and they are listed below.
1. public
2. private
3. protected
4. default(no specifier)

3. Describe default constructor


A default constructor is a constructor that either has no parameters, or if it has parameters, all
the parameters have default values. This constructor is an inline public
member of its class. The compiler will implicitly define A::A() when the compiler uses this
constructor to create an object of type A .

4. Express what is meant by java package


A Package can be defined as a grouping of related types(classes, interfaces, enumerations and
annotations ) providing access protection and namespace management.
Some of the existing packages in Java are −
java.lang − bundles the fundamental classes
java.io − classes for input , output functions are bundled in this package.

5. Illustrate with example how to import a single package?


Types of packages in Java: built-in packages and the packages we can create (also known as
user defined package).
import java.util.Scanner Here:
→ java is a top level package
→ util is a sub package
→ and Scanner is a class which is present in the sub package util.

6. Explain the features of Java


• * Simple: The Java language is easy to learn. ...
• * Familiar: Java is similar to C/C++ but it removes the drawbacks and complexities of C/C++
like pointers and multiple inheritances. ...
• * Object-Oriented: ...
• * Robust: ...
• * Secure: ...
• * High Performance: ...
• * Multithreaded: ...
• * Platform Independence:

7. What is API Package


Java application programming interface (API) is a list of all classes that are part of the Java
development kit (JDK). It includes all Java packages, classes, and interfaces, along with their
methods, fields, and constructors.

8. Define inheritance hierarchy. Give an example


In object-oriented programming, inheritance enables new objects to take on the properties of
existing objects. A class that is used as the basis for inheritance is called a superclass or base class. A
class that inherits from a superclass is called a subclass or derived class.

9. What is meant by abstract classes


In Java, we can have an abstract class without any abstract method. This allows us to create
classes that cannot be instantiated, but can only be inherited. 4) Abstract classes can also have final
methods (methods that cannot be overridden)

10. In java describe the use of Interfaces?


Interfaces are more flexible, because a class can implement multiple interfaces. Since Java
does not have multiple inheritance, using abstract classes prevents your users from using any other
class hierarchy. In general, prefer interfaces when there are no default implementations or state.
PART-B(10*3=30)

11. 1 Explain the types of package with its importance

i.What is method? How method is defined? give example(6)

(OR)

ii. State the purpose of finalize() method in java? With an example explain how finalize() method can
be used in java program(7)

i.What is class? how do you define a class in java(6)

12. Illustrate with an example the following features of constructors:

i. Default constructors (2)

ii. Parameterized constructor (2)

iii. Overloaded constructors (2)

iv. A call to another constructor with this operator( 2)

v. An object initialization block(2)

vi. A static initialization block(3)

(OR)

i.Illustrate OOPS and explain the features of OOPS (7)

ii. Demonstriate the static felds and methods used in java (6)

13. Define Inheritance? With diagrammatic illustration and Java programs illustrate the different types of
inheritance.

(OR)

. Write briefly on Abstract classes with an example

You might also like