0% found this document useful (0 votes)
103 views7 pages

INTRODUCTION TO JAVA Question With Answer 2018

This document contains questions about Java programming language concepts for an exam. It includes multiple choice and subjective questions covering topics such as: Java's use as a compiled, interpreted, and hybrid language; Java Virtual Machine functionality; differences between applications and applets; wrapper classes; dynamic billboard applets; multitasking in Java; Remote Method Invocation; Java Database Connectivity; Swing components; designing Java classes; socket programming in Java; interfaces; StringBuilder class; object passing; JDBC drivers; listener methods; Java exceptions; and polymorphism.

Uploaded by

MUDABBIR RASHID
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)
103 views7 pages

INTRODUCTION TO JAVA Question With Answer 2018

This document contains questions about Java programming language concepts for an exam. It includes multiple choice and subjective questions covering topics such as: Java's use as a compiled, interpreted, and hybrid language; Java Virtual Machine functionality; differences between applications and applets; wrapper classes; dynamic billboard applets; multitasking in Java; Remote Method Invocation; Java Database Connectivity; Swing components; designing Java classes; socket programming in Java; interfaces; StringBuilder class; object passing; JDBC drivers; listener methods; Java exceptions; and polymorphism.

Uploaded by

MUDABBIR RASHID
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/ 7

INTRODUCTION TO JAVA

PROGRAMMING LANGUAGE
AKU QUESTIONS 2018

MCQ QUESTIONS:

a) Java is an example of ___ language.

(i) compiled

(ii) interpreted

(iii) hybrid

(iv) script

(b) The mother tongue of a computer is

(i) assembly language

(ii) machine language

(iii) BASIC language

(iv) None of the above

(c) You have the following code in a file called Test.java -

class Base{
public static void main(String|] args){

System.out.println("Hello’);
}

}
public class Test extends Base}

What will happen if you try to compile and run this?


(i) It will fail to compile

(i) Runtime error

(iii) Compiles and runs with no output

(iv) Compiles and runs printing "Hello"

(d) Which of the following are valid declarations?


Note : None of the literals used here contain the character O,
they are all Zeroes.

(i) int i = OXCAFE;

(i) boolean b = 0;

(iii) byte b = 128;

(iv) char c = "A";

(e) What is the result of trying to compile and run this


program?

public class Test{


public static void main(String[] args){
int[ja = {1};
Test t = new Test();

t.increment(a);
System.out.printin(a{a.length- 1));

void increment(intl]i}{
ifidength - 1]++;
}

(ij Compiler error


(i) Compiles and runs printing out 2
(ii) Compiles and runs printing out |
(iv) An ArrayIndexOutOfBounds Excep-
tion at runtime

(f) Is this legal?

long longArrf];
int intArr[] = (7, 8, 9};
longArr = intArt;

(i) Yes
(ii) No

(g) What is the result of attempting to compile and run this?

interface A[
void aMethod();

public class Test implements A{


void aMethod(){
System.out.printin("hello");
}

public static void main(String|jargs}{


Test t = new Test);

t.aMethod();

}
}
(i} The code will not compile
(i) Runtime exception
(ii} Compiles and runs printing out
"hello"

(h) What are the class variables?

(i) Explain the following code sample :


result = someCondition ? valuel : value2;

(j) Character strings are represented by the class _____

SUBJECTIVE QUESTIONS:

2. (a) Why is Java called machine independent


Language? Explain the functionality of JVM.
Ans:-
Java compiler produces a unique type of code called bytecode
unlike c compiler where compiler produces only natively executable
code for a particular machine.
When the Java program runs in a particular machine it is sent to
java compiler, which converts this code into intermediate code
called bytecode. This bytecode is sent to Java virtual machine
(JVM) which resides in the RAM of any operating system. JVM
recognizes the platform it is on and converts the bytecodes into
native machine code. Hence java is called platform independent
language.

JVM is the core of the Java platform and is responsible for:

1. Loading bytecodes from the class files


2. Verifying the loaded byte codes
3. Linking the program with the necessary libraries
4. Memory Management by Garbage Collection
5. Managing calls between the program and the host environment.
(b) What is the main difference between an application and
applet?

3. (a) What are the wrapper classes? Explain their uses.

(b) What does a dynamic Billboard Applet do? What are the
three main classes that the applet contain?

4. (a) What is the difference between process- based and


thread-based multitasking? Give the two ways by which a
thread can be created using Java.

(b) What is RMI? What is the difference between Naming.bind


and Naming.rebind methods? Write a short code to invoke a
remote method using Java RMI.

5. Write an Applet (Use swings) to display the following


outputs :

6. (a) What are the characteristics of JDBC? What are the


various steps for using JDBC? Write a program to demonstrate
these steps.
(b) What is the main purpose of a container component in
swing?

7. Design a class named Fan to represent a fan. The class


contains :

 Three constants named SLOW, MEDIUM and FAST with


values 1, 2 and 3 to denote the fan speed.

 A private int data field named speed that specifies the


speed of the fan (default SLOW).

 A private boolean data field named on that specifies


whether the fan is on (default false)

 A private double data field named radius that specifies the


radius of the fan (default 5).

 A string data field named colour that specifies the colour of


the fan (default blue).

 The accessor and mutator methods for all four data fields.

 A no-arg constructor that creates a default fan.

 A method named toString) that returns a string description


for the fan. If the fan is on, the method returns the fan
speed, colour, and radius in one combined string. If the fan
is not on, the method returns fan colour and radius along
with the string “fan is off in one combined string.
Implement the class. Write a test program that creates two
Fan objects. Assign maximum speed, radius 10, colour
yellow, and turn it onto the first object. Assign medium
speed, radius 5, colour blue, and turn it off to the second
object. Display the objects by invoking their toString
method.

8. Write a program in Java to demonstrate communication


using TCP/IP ie., using sockets. Write a separate code for a
server and client program. The program should display the
contents of the file specified in a server onto the client.

9. Write short notes on the following :

1) Interface
2) String builder class
3) Object passing
4) Types of JDBC drivers
5) Listener method
6) Java exceptions
7) Polymorphism

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy