0% found this document useful (0 votes)
157 views5 pages

1st Assignment Answer

The document contains 11 multiple choice questions about Java. It tests knowledge of key topics like the name of the team that developed Java (Sun), the tool used for compiling Java programs (javac), and additions in Java 7 like string switches. It also contains review questions about Java concepts such as why it is platform independent, the security model, and multithreading. The steps for executing a Java program are provided as well as the importance of tools in the JDK like javac, java, and environment variables.

Uploaded by

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

1st Assignment Answer

The document contains 11 multiple choice questions about Java. It tests knowledge of key topics like the name of the team that developed Java (Sun), the tool used for compiling Java programs (javac), and additions in Java 7 like string switches. It also contains review questions about Java concepts such as why it is platform independent, the security model, and multithreading. The steps for executing a Java program are provided as well as the importance of tools in the JDK like javac, java, and environment variables.

Uploaded by

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

Objective Questions

1. What was the name of first version of Java?


(a) Oak (b) Mustang
(c) Tiger (d) Playground

Ans. Option (a) Oak

2. What was the name of the team that developed Java?


(a) Green Team (b) Star Seven
(c) Sun (d) Java team

Ans. Option (c) Sun

3. What is the name of the tool that is used for compiling a Java program?
(a) javap (b) java
(c) javah (d) javac

Ans. Option (d) javac

4. What is the name of the tool that is used for interpreting a Java program?
(a) javap (b) java
(c) javah (d) javac

Ans. Option (b) java

5. What process automatically removes objects that are not being referenced?
(a) Multithreading (b) Object Reclamation
(c) Garbage collection (d) Object collection

Ans. Option (c) Garbage collection

6. What is the name of the tool that is used for running Applets?
(a) javap (b) javac
(c) java (d) appletviewer

Ans. Option (d) appletviewer

7. What is the extension of the source files in Java?


(a) .jav (b) .java
(c) .bytecode (d) .class

Ans. Option (b) .java

8. What is the extension of the bytecode files in Java?


(a) .jav (b) .java
(c) .class (d) .bytecode

Ans. Option (c) .class

9. Which all are correct for main method?


(a) public static void main(String args[])
(b) private static void main(String args[])
(c) static void main(String args[])
(d) public static void main(String a[])

Ans. Option (a) public static void main(String args[]) , (d) public static void main(String a[])

10. Which of the following are added in Java 7?


(a) String in switch case
(b) meta data
(c) annotations
(d) automatic resource management

Ans. Option (a) String in switch case, (d) automatic resource management
Review Questions

1. Why is Java known as a platform-independent language?

Ans. Platform independent language means once compiled you can execute the program on any platform (OS).
Java is platform independent. Because the Java compiler converts the source code to bytecode, which is Intermidiate Language. Bytecode can be
executed on any platform ( OS ) using JVM( Java Virtual Machine). Every platform have their own JVM with it.

2. Explain the security model of Java that makes it more secured than other languages.

Ans. The Java security model, introduced in Java 2, is the basis of highly secured and distributed enterprise Java applications. The model is based on a
customizable "sandbox" in which Java software programs can run safely, without potential risk to systems or users. Java security technology
includes a large set of APIs, tools, and implementations of commonly used security algorithms, mechanisms, and protocols.

3. Why is Java known to be multithreading? How does it help Java in its performance?

Ans. Java is desinged to meet the real world requirement of creating interactive , networked program. To accomplish this, java supports multi-threading
programming, which alloow you to write program that do many task. Java run time system comes with an elegent yet sopheticated solution for
multipurpose synchronization that allow you construct smooth running intreacting system.

4. C++ is an object-oriented language older than Java, then why did Java replace C++ in most of the application development?

Ans. Java is a general purpose, object oriented programming language. Both C and C++ has limitations of reliability and portability whereas Java is very
simple, portable and highly reliable. The most striking feature of Java is that it is platform neutral language. It is the first programming language that
is not tied to any particular hardware or operating system. Some more feature of java which playes great role in replacing C++ are as follow-

- Rich GUI library .


- better web frame work.
- platform independent.
- better security.
- ease of maintanance.
- huge community support to noobies.

5. Java had middle-tier capabilities. What does this statement mean?


Ans. Error 404 not found........ : ) lol.....

6. Java was used in Internet applications. Cite reasons.

Ans. The following are the reasons why java were used in internet-

java applets and applications:


An application is a program that runs on your page on computer. it is Java's ability to create applets that makes it important. an Applet is an
application designed to be transmitted over the Internet and executed by a Java-compatible Web browser.

security:
Prior to Java, most users did not download executable programs frequently, and those who did scanned them for viruses prior to execution.
When you use a Java-compatible Web browser, you can safely download Java applets without fear of viral infection or malicious intent.
Java achieves this protection by Confining a Java program to the Java execution environment and not allowing it access to other parts of
the computer.

portability:
Many types of computers and operating systems are connected to the Internet. For programs to be dynamically downloaded to all the
various types of platforms connected to the Internet. some means of generating portable executable code is needed.

Robust :
memory management mistakes and mishandled exceptional conditions.

Multithreaded:
Java supports multithreaded programming, which allows you to write programs that do many things simultaneously.

interpreted and high performance:


Java enables the creation of platform programs by compiling into an intermediate representation called Java bytecode. This code can be
interpreted on any system that provides a Java Virtual Machine java was designed to perform well on very low-power CPUs.

Distributed:
Java is designed for the distributed environment of the Internet.

Dynamic:
java programs carry with them substantial amounts of run-time type information that is used to verify and resolve accesses to objects at
run time.

7. Explain the importance of JVM in JRE.

Ans. A Java virtual machine (JVM) is a virtual machine that enables a computer to run Java programs as well as programs written in other languages
that are also compiled to Java bytecode. The JVM is detailed by a specification that formally describes what is required in a JVM implementation.
Having a specification ensures interoperability of Java programs across different implementations so that program authors using the Java
Development Kit (JDK) need not worry about idiosyncrasies of the underlying hardware platform.

8. Explain the structure of a Java program.

Ans.
public class Test // 1
{ // 2
public static void main( String args[ ] ) // 3
{ // 4
// this is the basic structure of a java program. // 5
} // 6
} // 7

The following are the work of every line in this program-

1- declaration of the class “Test” is mentioned in first line. This class is a public class, as the access permittion is “public”.
2- “ { “ opening braces indicate the starting/begning of the body of class “Test”.
3- declaration of main method of “Test” class, the method is having the public access permission and is static in nature[i.e it doesn’t need a
object to get called], and its return type is void [i.e it dosen’t return anything ].
4- “ { “ opening braces indicate the starting/begning of the body of class “main”.
5- This line is not compulsory in any program. Its just a comment which is not considered to be code and the compiler ignores it during
execution of code.
6- “ } “ closing braces indicate the ending of the body of method “main”.
7- “ } “ closing braces indicate the ending of the body of class “Test”.

9. Explain the steps for executing a Java program.

Ans. The following are the steps to execute java program -


- First write your java program in text editor.
- Then save it with “.java” extension.
- Navigate to the location where the program file is situated , with command prompt.
- Type “javac” followed by the name of program file . Ex- javac Test.java .If no error occure, a .class file will be generated and thats our byte
code.
- Then type “java” followed by the name of file only. Ex- java Test.

10. What is the importance of setting environment variables such as Path and Classpath?

Ans. When a user enters a particular command in Command Prompt[Windows] or Terminal [Unix/Linux], the Operating System [OS] searches for the
executable file of that command in the current directory [ From where user enters the command ]. If it is not there, OS checks the values stored in
PATH environment variable . These values are nothing but a list of directories with their absolute paths. OS checks for the executable files of that
particular command one by one in these directories and if it fails to find it in any of these directories, an error will be displayed.

11. Discuss the tools available in JDK. How do they help in application development?
Ans.

Java Tool Description


appletviewer To run applets outside of a web browser.
extcheck To detect version conflict between a target jar file and installed extension jar files.
idlj To generate Java bindings for a given IDL file.
To enable Java applications that implement Java Accessibility API to be visible to assistive technologies on MS
jabswitch
Windows systems.
jar To aggregate and compress multiple files into a singe JAR file.
jarsigner To digitally sign a jar file and also to verify the signatures and integrity of signed jar files.
java To launch Java applications.
javac To compile Java source files to binary class files.
javadoc To generate API documentation out of Java source files.
javafxpackager To package JavaFx applications for deployment.
javah To generate C language header and stubs while writing native methods.
javap To disassemble Java class files.
java-rmi To generate stubs, skeletons and other RMI related tasks.
javaw To run a GUI based Java application in its own window in MS Windows.
javaws To launch a Java application that is distributed through web.
jcmd To send diagnostic command requests to a Java JVM.
jconsold GUI tool to monitor a Java application running in a JVM.
jdb To debug a Java class.
jdeps To analyze Java class dependencies.
jhat To parse and browse through Java heap dumps.
jinfo To print configuration information for a given process or core file or remote debug server.
jjs To invoke the Nashorn JavaScript engine.
jmap To print shared object memory maps or heap memory details of a Java application process.
jmc To monitor, analyze and debug Java applications.
jps To list instrumented HotSpot Java VMs on a target system.
jrunscript To run scipting language files like JavaScript.
jsadebugd To attach to a Java process and acts as a debug server, so that remote clients can connect to it.
jstak To print stack trace of threads for a given Java process.
jstat To display performance statistics for an instrumented HotSpot JVM.
jstatd To launch a RMI server to monitor creation and termination of instrumented HotSpot Java virtual machines.
jvisualvm To monitor, analyze and debug running Java application via a GUI.
keytool To create, manage, store keys and security certificates.
kinit To obtain and cache Kerberos ticket-granting tickets.
klist To list entries in credential cache and key tab.
ktab To manage the entries in the security key table.
native2ascii To convert files encoded in any character encoding supported by JRE to files encoded in ASCII.
orbd To locate and invoke persistent objects on servers in CORBA environments.
pack200 To transform a Java JAR file into a compressed pack200 file using the Java gzip compressor.
policytool To create and modify the external policy configuration files that define the system Java security policy.
rmic To generate stubs and skeletons for Java remote objects.
rmid To start the activation system daemon that allows remote objects to be registered and activated in a JVM.
rmiregistry To start a remote object registry.
schemagen To generate schema for Java architecture XML bindings.
serialver To return Java class serialVersionUID.
servertool To enable programmers to register, unregister, startup and shutdown a persistent server.
tnameserv To provide access to Java naming service.
unpack200 To transform back a pack200 file to a Java JAR file.
wsgen To read an existing web service implementation class and generate Java JAX-WS portable artifacts.
wsimport To read a WSDL and generate Java JAX-WS portable artifacts.
xjc Binding compiler for Java Architecture for XML Binding.
Programming Exercise

1. Write a program to print ‘Welcome’ followed by your name and ‘How are you?’

Program-

import java.util.Scanner;

public class Test


{
public static void main(String args[ ])
{
Scanner input = new Scanner( System.in );
String name;

System.out.print("Enter Your name - ");


name = input.next();

System.out.printf("\nWelcome %s. How are you ?\n", name);


}
}

You might also like