Java programming
S. No. Questions
Explain the event delegation models in AWT.What are the components of an
event?
Explain the concept of interface. What is scope and nature of variables and
methods defined in an interface?
a) How does exception-handling work in Java?
3
b) Why Java doesn't support multiple inheritances?
a) State the significance of public, private, protected, default modifiers
4
b) What are different types of inner classes?
What is a static method? Why cant a static method use this and super? Explain
with example
Explain the concept of method overriding. Can we over-ride method within the
same class? Explain.
a) What are native methods? How do you use them?
7
b) What are wrapper classes? Why are they used?
What are the most important features of Java? How does Java achieve platform
Marks - 10
independence?
Assignment B
Case Detail : Read the following and create appropriate java applets.
a. Create a try block that is likely to generate two types of exception and then
incorporate necessary catch block to handle them appropriately
b) Create a java applet with a button Display. On click of button it should display
Rectangle, Oval and Circle within the Applet.
c) Create the following form in Java:-
1.
Subject should display name of subjects :-c++, VB, Java
2.
Foreign language should display choice of foreign languages French, German and Japanese.
3.
Submit button should submit the result.
Assignment C
Question No: 1
Which of the following expressions will produce errors upon compilation?
(A) boolean a = (boolean) 1;
(B) boolean b = (false && true);
(C) float y = 22.3;
(A) & (C)
(A)
(A), (C) & (D)
(A), (B) & (D)
Question No: 2
Which of the following expressions will produce errors upon compilation?
(A) boolean a = (boolean) 1;
(B) boolean b = (false && true);
(C) float y = 22.3;
(A) & (C)
(A)
(A), (C) & (D)
(A), (B) & (D)
Question No: 3
The control expression in an "if" statement must be--
an expression with type boolean
an expression with type integer
an expression with either the type boolean or integer
an expression with either the type boolean or integer with value 0 or 1
Question No: 4
Which of the following represent legal flow control statements?
(A) break;
(B) break();
(C) continue outer;
(D) continue(inner);
(E) return;
(F) exit();
(A), (C) & (E)
(A), (B) & (C)
(A), (C) & (D)
(A) & (E)
Question No: 5
Which of the following represent legal flow control statements?
Are there any errors in the following class definition?
abstract class Class1
Class header definition is wrong
Method definition is wrong
Constructor needs to be defined
No errors
Question No: 6
With javadoc, which of the following denotes a javadoc comment?
/**
//#
/*
//**
Question No: 7
Which javadoc tag is used to denote a comment for a method parameter?
@param
@method
@parameter
@argument
Question No: 8
What will be the result of the expression?
a%b
when a and b are of type int and their values are a = 10 and b = 6?
1.66
1
None of these
4
Question No: 9
Determine the output when the value of x is zero--
if(x >= 0)
if(x > 0)
System.out.println("x is positive");
else
System.out.println("x is negative");
"x is negative"
"x is positive"
"x is positive" and "x is negative"
None of these
Question No: 10
Which of the following is correct syntax for an Abstract class?
abstract double area() { }
abstract double area()
abstract double area();
abstract double area(); { }
Question No: 11
What is the output of following piece of code?
int x = 2;
switch (x) {
case 1:System.out.println(1);
case 2:
case 3:System.out.println(3);
case 4:
case 5:System.out.println(5);
}
No output
3&5
1, 3 & 5
3
Question No: 12
__________ converts the java program to byte code.
Java Virtual Machine
Compiler
Java Libraries
Java Editor
Question No: 13
What would happen if you dont include String args[] in the main method of any class?
No error
Compile error
Runtime Error
No error but goes to infinite loop
Question No: 14
JVM stands for--
Java Vision Mechanism
Java Virtual Machine
Java Virtual Model
Java Vertical Model
Question No: 15
Java consists of a ready-made package called--
Java Program
Java Applet
Java API
Java Widgets
Question No: 16
Java Platforms consists of --
Java Program and Applet
Java API and JVM
Java Widgets and Programmes
Java Virtual Machine and Applets
Question No: 17
Which of the following are not logical operators?
>>
&&
!
^
Question No: 18
Java was developed by--
Microsoft
Sun Microsystems
Borland
Siemens
Question No: 19
Which of the following variable is valid in Java?
variable1
variable2_n
variable=
variable 4
Question No: 20
What is the result of the following operation?
System.out.println (4 / 3)
6
0
1
7
Question No: 21
To compile a java file, path should be set to-{ c:\is the drive where jdk1.4 is installed}
c:\ jdk1.4\lib;
c:\jdk1.4\bin;
c:\jdk1.4\include;
None of the above
Question No: 22
In java ________ is the top hierarchy of the classes.
Class Name
Object
Main Method
Super Class
Question No: 23
Using the keyword_____________, we can access value of the instance variables and class variables of
that class inside the method of that class itself.
Super
this
final
Either final or this
Question No: 24
The number of arguments or the types of arguments is to be different for creating two or more methods
with the same name are in--
Inheritance
Method overloading
Method overriding
Polymorphism
Question No: 25
The keyword new will--
Create an instance of a object
Create the instance of a class
Assigns a new value to the object
Create new object by instantiating the class
Question No: 26
What are the five layouts of AWT?
a) BagGridLayout
b) FlowLayout
c) GridLayout
d) BagLayout
e) GridBagLayout
f) CardLayout
g) BorderLayout
bcefg
abcde
fgeda
acbge
Question No: 27
Events do not respond to--
Physical Action
Logical Action
Astrological Action
All of the above
Question No: 28
Checkbox, Menu item, and choice Lists event can be handled by --
Adjustment Listener
Item Listener
Action Listener
Text Listener
Question No: 29
Signature of the method includes--
Name of the Method
List of parameters
Return type of the method
Only a) and b)
Question No: 30
Break statement is used for--
To break the control of the program
To stop the loop execution of a program
To break the particular code execution
To jump out of the loop
Question No: 31
Constructor method will be created--
While compiling
While executing
When object is created
When class is created
Question No: 32
Expansion of DNS is--
Distributed Name Service
Domain Name System
Domain Name Service
Domain Navigation Service
Question No: 33
What do you mean by abstract class?
The class, which cannot have its sub classes
A general class with name abstract
The class cannot have its own instances of objects
The classes used for implementations are called as abstract
Question No: 34
This is the java syntax to declare a subclass--
Class subclass: public super class
Subclass extends super class
Class subclass inherits super class
Class subclass extends super class
Question No: 35
What tags are mandatory in HTML to display an applet?
Name, Height, Width
Codebase, Height, Width
Code, height, Width
Code
Question No: 36
What do you mean by literal in Java?
It is a keyword in Java
All Java variables are called as literals
It is a value assigned to primitive or abstract data type variables
Literal is an object that exists and executed on the local machine
Question No: 37
What do you mean by literal in Java?
It is a keyword in Java
All Java variables are called as literals
It is a value assigned to primitive or abstract data type variables
Literal is an object that exists and executed on the local machine
Question No: 38
Differentiation between component and container classes in Java is--
Container is the super class of the components
Components are the super class of the containers
Component can hold only one object, whereas container can have single or collection of objects
There is no difference at all
Question No: 39
What do you mean by final method in Java?
Name of the method defined
Name of the class, of which this method is declared
This is one, which cannot be overridden by ant subclasses
This is the Java syntax to declare a subclass
Question No: 40
The type of Java programs are--
Applications
Applets
Servlets
Packages