Professional Documents
Culture Documents
<CO, IF>: <22412>: < Java Programming >: < Basic Syntactical Constructs in Java >: <LO1>: <Assessments>:
<Formative>
<Yogita Jore>
___ is the extension of java source file. Bytecode is the instruction set for _____ is the extension of Bytecode file.
_______.
Ans: <.java> Ans: < Java Virtual Machine > Ans: <.class>
Set 2: Question No 1 Set 2: Question No 2 Set 2: Question No 3
Identify the incorrect Java features. _____tool is used to find and fix bugs in _______ of the following option leads to
the Java programs. the portability and security of Java.
Ans: < Use of pointers > Ans: <JDB> Ans: < Bytecode is executed by JVM >
Set 2: Question No 1 Set 2: Question No 2 Set 2: Question No 3
______of keywords is used to make a ______ of the following is a valid Identify the stored value in the object obj
class. declaration of an object of class Box. in following lines of Java code.
box obj;
Ans: < class > Ans: <Box obj = new Box();> Ans: < NULL>
Assessment Type: Summative: End of LO: in LMS
______ component is ______ of the following ____ number of Identify the statement _____ component is
used to compile, debug tool is used to generate threads can be is true about java. responsible for
and execute java API documentation in executed at a time. converting bytecode
program. HTML format from doc into machine specific
comments in source code.
code.
Ans: < JDK > Ans: < Javadoc tool > Ans: < Multiple threads Ans: < Platform Ans: < JVM >
> independent
programming language
>
Assessment Type: Practice Worksheets: End of CO: in LMS/ downloadable PDF
Java is Dynamic:
By connecting to the Internet, a user immediately has
access to thousands of programs and other computers.
During the execution of a program, Java can
dynamically load classes that it requires either from
the local hard drive, from another computer on the
local area network or from a computer somewhere on
the Internet.
Java is an Object Oriented Language:
Everything in java is an object. All program code and data Java is Robust and Secure language:
reside within objects and classes. Java comes with an Java provides many safeguards to ensure reliable code.
extensive set of classes, arranged in packages that can use in Java has the strong memory allocation and automatic
our programs by inheritance. As the languages like Objective garbage collection mechanism. It provides the
C, C++ fulfils the four characteristics (Inheritance, powerful exception handling and type checking
Encapsulation, Polymorphism and Dynamic Binding) yet mechanism as compared to other programming
they are not fully object oriented languages because they are languages. Compiler checks the program whether
structured as well as Object Oriented Languages. But in case there are any errors and interpreter checks any run
of java, it is a fully Object Oriented Language because object time errors and makes the system secure from crash.
is at the outer most level of data structure in java. No stand- All of the above features make the java language
alone methods, constants, and variables are there in java. robust.
Everything in java is object even the primitive data types can With Java secure feature it enables to develop virus-
also be converted into object by using the wrapper class. free, tamper-free systems used in internet. The
absence of pointers in Java ensures that programs
Java is Distributed language: cannot gain access to memory locations without
Java is designed for the distributed environment of the proper authorization. Authentication techniques are
internet. The widely used protocols like HTTP and FTP are based on public-key encryption.
developed in java. Internet programmers can call functions on
these protocols and can get access the files from any remote
machine on the internet rather than writing codes on their
C. Java is not 100% object oriented language. Justify D. Explain the way to declared object and
class in java?
Ans: According to this assumption, there are several reasons Ans:
why Java is not a 100% Object Oriented Programming Declaring Class:
Language: Class is a user defined data type. Once a new data type
1) Primitive data types (int, char, floats, etc.) are not is defined using a class, it can be used to create objects
an object and couldn’t be defined as an object, of that type. A class is a template for an object and
neither a class. It is clear enough, because primitive object is an instance of a class. Classes create objects
data don’t have any ability/characteristic such as and objects use methods to communicate between
inheritance or polymorphism. So, we can say that them.
Java can be defined as not fully OOP supported Syntax:
language, since it’s allowed a non-object-oriented class classname [ extends superclassname]
thing to exist. int, float, etc. primitive data types are {
not objects. But java implemented Wrapper classes [ fields declaration; ]
for these primitive types to make them in to object [ methods declaration; ]
types. }
2) Multiple-inheritance through classes is not Example:
possible: As same as the operator overloading, class rectangle
multiple inheritance is also an (ad-hoc) abilities. It {
does support multiple inheritances directly, instead int length, width; //declaration of variables
of that we can use interfaces, and with the help of void getdata(int x, int y)
interface implicitly we can use multiple //definition of method
inheritances. { length = x;
3) Availability of static methods and variables: Since width = y;
this ability exists in Java, which allows developers to }
invoke a method without instantiating any object Rules for defining classes:
like breaking rules of encapsulation. Everything inside the square brackets is optional.
4) Operator overloading is not possible in java: No semicolon after closing curly bracket.
Except “+” operator which can be used in two Classname and superclassname are any valid java
different operations (addition operation and identifiers.
concatenation of string), there is no possibilities in The keyword extends indicates that the
Java to do an operator-overloading. Since, this is a properties of the superclassname class are
kind of polymorphism ability (specific for operators) extended to the classname class. This concept is
we also could say that Java isn’t 100% OOP known as inheritance.
Language. The data or variables defined within a class are
called instance variables.
Collectively the methods and variables defined
within class are called members of the class.
Object:
It is a basic unit of Object-Oriented Programming and
represents the real life entities. A typical Java program
creates many objects, which as you know, interact by
invoking methods.
Initializing an object:
Classes provide constructor methods to initialize a new
object of that type. A class may provide multiple
constructors to perform different kinds of initialization
on new objects.
For example:
Rectangle rect1=new Rectangle (10, 20);
E. Explain the steps to execute java code?
Ans:
Compilation and Execution of Java Program
1. Create a program using any text editor (use notepad editor
in Windows Operating System). Open notepad and enter/edit
the following program.
class Test
{
public static void main(String args[])
{
System.out.println(“Hello! ”);
System.out.println(“Welcome to the world
of java ”);
System.out.println(“Let us learn java ”);
}
}
5. Go to bin directory.