0% found this document useful (0 votes)
4 views9 pages

Unit 1 2marks

The document provides an overview of Object Oriented Programming (OOP) concepts, features of Java, and key components such as objects, classes, and methods. It discusses Java's characteristics, memory allocation for objects, access specifiers, variable types, control statements, and constructors. Additionally, it covers the differences between static and non-static members, as well as the finalize method for resource management.

Uploaded by

jayasuryarsj1409
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)
4 views9 pages

Unit 1 2marks

The document provides an overview of Object Oriented Programming (OOP) concepts, features of Java, and key components such as objects, classes, and methods. It discusses Java's characteristics, memory allocation for objects, access specifiers, variable types, control statements, and constructors. Additionally, it covers the differences between static and non-static members, as well as the finalize method for resource management.

Uploaded by

jayasuryarsj1409
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/ 9

PART – A

1. What is meant by Object Oriented Programming? (U)

OOP is a method of programming in which programs are organized as


cooperative

Collections of objects. Each object is an instance of a class and each class


belong to a hierarchy.

2. List out features of OOPS. (NOV/DEC2011 ) ®

➢ Inheritance

➢ Polymorphism

➢ Data Hiding

➢ Encapsulation

➢ Overloading

➢ Reusability

3. Mention the features of Java. (NOV/DEC 2013, NOV/DEC 2015) ®

There are many features of java. They are also known as java buzzwords.

1. Simple Object-Oriented

2.

Platform independent

3. Secured

4. Robust

5. Architecture neutral

6. Portable

7.

Dynamic

8. Interpreted

9. High Performance

10. Multithreaded
11. Distributed

4. Define Objects and classes in java. (NOV/DEC 2010, NOV/DEC 2011)


(NOV/DEC 2018) ®

Objects: Object is an instance of a class and it is a software unit that


combines a structured set of

Data with a set of operations for manipulating that data. It has state,
behavior and

Identity.

Classes: Cass is a collection of similar objects. It contains data and


functions bundled together

Under a unit. In other words “Class is a template for a set of objects


that

Share a

Common structure and a common behavior”.

4. What is a Byte Code (Platform Independent Codes)? (U)

Byte code is a highly optimized set of instructions designed to be executed


by the Java run-

Time system which is called the Java Virtual Machine (JVM). Byte code
is the machine code instructions for the JVM and JVM is an Interpreter for
Byte code.

5. What is Java Virtual Machine (JVM)? (U)

JVM is an acronym for Java Virtual Machine. An abstract computing


machine, or virtual

Machine, JVM is a platform-independent execution environment that converts


Java bytecode into

Machine language and executes it.

6. What is meant by JIT compilation? Instant variable (APRIL/MAY 2012)


(U)

Just-In-Time compilation (JIT), also known as dynamic translation, is


compilation done
During execution of a program – at run time – rather than prior to
execution. Most often this

Consists of translation to machine code, which is then executed directly.

An instance variable is a variable that is declared in a class, but outside a


method, constructor

Or any block. Instance variables are created when an object is created with
the use of the keyword

‘new’ and destroyed when the object is destroyed.

7. Can a java source file be saved using the name other than the class
name? – justify

(APR/MAY 2019) (AN)

Yes, we compile a java file with a different name than the class, provided that
there should not be

Any public class in that file.

If there is any public class in file then in that case, we have to give that name
as file name. But if

Our class does not contain any public class then we can give any name to
our class.

8. List the parts of a simple Java program. ®

➢ Object

➢ Class

➢ Method and

➢ variables

9. What are access specifiers? (NOV/DEC 2018, NOV/DEC 2019) (U)

Access specifiers are used to specify the visibility and accessibility of


a class constructors,

Member variables and methods. The four levels of access specifiers in Java
are:

1. Public – anything declared as public can be accessed from anywhere.

2. Private – anything declared as private can’t be seen outside of the class.


3. Protected – anything declared as protected can be accessed by classes in
the same package and

Subclasses in the other packages.

4. Default – can be accessed only by the classes in the same package.

5. Others: 1. Static

2. Final

11. What are the different types of variables in Java? ®

There are three kinds of variables in Java:

Local variables – Local variables are declared in methods, constructors, or


blocks.

• Instance variables - Instance variables are declared in a class, but

Outside a method, constructor or any block.

Class/static variables – Class variables also known as static variables are


declared

With the static keyword in a class, but outside a method, constructor or a


block.

12. Define an Array. ®

An array is a data structure that stores a collection of values of the same


type.

13. Define ragged arrays. ®

It is a new feature supported by Java. In Ragged arrays, each row, in


a two-dimensional

Array, may contain different lengths. Let us design a two-dimensional array


with 4 rows where the

First row contains 4 elements, the second row with 1 element, the third row
with 2 elements and

The fourth row with 3 elements.


14.

List the various categories of operators in Java. ®

Java operators fall into eight different categories:

1. Assignment

2. Arithmetic

3. Relational

4. Logical

5. Bitwise

6. Compound assignment

7. Conditional

8. Type.

15. What is the use of Control Statements? (U)

Java Control statements control the order of execution in a java


program, based on data

Values and conditional logic.

16.

Mention the types of Control Statements. ®

There are three main categories of control flow statements:

✓ Selection statements: if, if-else and switch.

✓ Loop statements: while, do-while and for.

✓ Transfer statements: break, continue, return, try-catch-finally and assert

17. Give the syntax of Enhanced “for” Loop. ®

The syntax of enhanced for loop is:

Declaration: The newly declared block variable, which is of a type


compatible with the elements of the array you are accessing. The
variable will be available within the for block

And its value would be the same as the current array element.

Expression: This evaluates to the array you need to loop through. The
expression can be an

Array variable or method call that returns an array.

18. How do you allocate memory for an object? ®

When an object is created using “new” operator, memory is allocated to an


object.

Eg: shape s = new shape();

19. What are the key characteristics of objects? (MAY/JUNE 2013) ®

All the objects have share the following three characteristics:

➢ Identity

➢ State

➢ Behavior

20.

What are methods and how they are defined? ®

Methods are functions that operate on instances of classes in which they are
defined.

Objects can communicate with each other using methods and call
methods in other

Classes. Method definition has four parts:

1. Name of the method

2.

Return type

3. List of parameters

4. Body of the method

A method signature is a combination of the first three parts.

21. What are static members? (U)


Static members (data and methods) are contained within the class
definition but accessed by

Without creating an instance of a class.

22. What is static variable and static method? (U)

Static variable: It is class variable whose value remains constant for the
entire class.

Static Method: is the one which can be called by using class name itself and
can hold only the

Static variables.

23. What is the difference between static and non-static variable? (NOV/DEC
2010) (AN)

Static variable: There is only one copy of static variable is created and even
when the class is

Instantiated, the value remains the same.

Non-static variable: Every time the class is instantiated, the object has their
own copy of these

Variables.

24. What is a constructor? ®

Constructor is a special method that performs an operation of creating object


and /or initializing

Its state.

25. List out the properties of a constructor.(R)

➢ A constructor has the same name as the class

➢ A class can have more than one constructor

➢ A constructor may take zero, one or more parameters

➢ A constructor h as no return value

➢ A constructor is always called with new operator

26. What is the difference between constructor and method? (AN)


Constructor

 Constructor is used to initialize the state of an object.


 Constructor must not have return type.
 Constructor is invoked implicitly.
 The java compiler provides a default constructor if you don’t have
any constructor.
 Constructor name must be same as the class Name.

Method

 Method is used to expose behavior of an Object.


 Method must have return type.
 Method is invoked explicitly.
 Method is not provided by compiler in any case.
 Method name may or may not be same as class name.

27. What is a Destructor? ®

Destructor is a function that frees the state of an object and/or destroys the
object itself. In Java,

There is no concept of destructors. It is taken care by the JVM.

28. What is a default constructor? (APRIL/MAY 2011) (U)

“Default constructor” refers to a constructor that is automatically generated


in the absence of

Explicit constructors (and perhaps under other circumstances); this


automatically provided

Constructor is usually a nullary constructor.

“Default constructor” may additionally refer to any constructor that


may be called without

Arguments. Two cases arise here: either it is a nullary constructor or


all of its parameters have

Default values.

29.

What is meant by parameter passing constructors? Give example. (NOV/DEC


2013)(U)
A parameter passing constructor, also called as parameterized
constructor, is a constructor

With one or more parameters.

30.Define finalize method in Java. (APRIL/MAY 2012, MAY/JUNE 2013) ®

Finalize() method is a method which is used to reclaim and recycle the


system resources when

It is no longer needed and to provide an unreachable object an


opportunity to perform any

Cleanup processing before the object is garbage collected.

You might also like