Академический Документы
Профессиональный Документы
Культура Документы
2 Mark
1. What do you mean by Bytecode?
Java bytecode is the result of the compilation of a Java program, an intermediate
representation of that program which is machine independent.
The Java bytecode gets processed by the Java virtual machine (JVM) instead of the
processor.
4. What is array? How to declare array and how to allocate the memory to for array?
a. Array is a collection of similar type of elements that have contiguous memory
location.
b. It is a data structure and store only fixed set of elements in a java array.
c. Array in java is index based, first element of the array is stored at 0 index
Declaration:
1. int mark[]; mark=new int[20];
2. int mark[]=new int[20];
3. int mark[]={10,20,30};
Where new is a special type operator that can be used to allocate memory for any array variable
5. Summarize any four Java doc comments.
Javadoc is a tool which comes with JDK and it is used for generating Java code
documentation in HTML format from Java source code, which requires documentation in
a predefined format.
6. What is a package?
A java package is a group of similar types of classes, interfaces and sub-packages.
Package in java can be categorized in two form, built-in package and user-defined
package.
Advantage of Java Package
1) Java package is used to categorize the classes and interfaces so that they can be
easilymaintained.
2) Java package provides accessprotection.
3) Java package removes namingcollision.
14. Can a java source file be saved using name other than the class name?
Yes,it is possible to compile a java source file with different file name but you need to make sure none of
the classes defined inside are public...when you compile the source file the corresponding .class files for the
classes inside the source file are created.
15. Illustrate constructor in java./What is a constructor? What are the rules for defining a constructor?
Constructors are special member functions whose task is to initialize the objects of itsclass.
It is a special member function; it has the same as the classname.
Java constructors are invoked when their objects are created. It is named such because, it
constructs the value, that is provides data for the object and are used to initializeobjects.
class Box {
double width; double height; double depth;
Box() // Default Constructor
{
width=height=depth=10;
}
Box(double i,doublej,double k)// Parameterized Constructor
{
width=i;
height=j;
depth=k;
}
}
19. Point out the justification of the statement “Java is platform independent”./How Java supports
platform independency?
The meaning of platform independent is that, the java source code can run on all operating
systems.
A compiler is a program that translates the source code for another program from a programming
language into executable code.
This executable code may be a sequence of machine instructions that can be executed by the CPU
directly, or it may be an intermediate representation that is interpreted by a virtual machine. This
intermediate representation in Java is the Java Byte Code.
13 mark
1. Characteristics of OOPS
2. Constructors
3. Package
4. Selection statements
5. Inheritance
6. Interface