Java

$10.00

SKU: AMSEQ-147 Category:

Assignment – A

Q1: Explain the event delegation models in AWT. What are the components of an event?
Q2: Explain the concept of interface. What is scope and nature of variables and methods defined in an interface?
Q3a) How does exception-handling work in Java?
Q3b) Why Java doesn’t support multiple inheritances?
Q4a) State the significance of public, private, protected, default modifiers
Q4b) What are different types of inner classes?
Q5: What is a static method? Why can’t a static method use ‘this’ and ‘super’? Explain with example
Q6: Explain the concept of method overriding. Can we over-ride method within the same class? Explain.
Q7: What are native methods? How do you use them?

Assignment – B
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

Q1: 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;
Answer Option
(A) & (C)
(A)
(A), (C) & (D)
(A), (B) & (D)

Q2: 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;
Answer Option
(A) & (C)
(A)
(A), (C) & (D)
(A), (B) & (D)

Q3: 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

Q4: 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)

Q5: 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

Q6: With javadoc, which of the following denotes a javadoc comment?
/**
//#
/*
//**

Q7: Which javadoc tag is used to denote a comment for a method parameter?
@param
@method
@parameter
@argument

Q8: 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

Q9: 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

Q10: Which of the following is correct syntax for an Abstract class?
abstract double area() { }
abstract double area()
abstract double area();
abstract double area(); { }

Q11: 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

Q12: __________ converts the java program to byte code.
Java Virtual Machine
Compiler
Java Libraries
Java Editor

Q13: What would happen if you donft include String args[] in the main method of any class?
No error
Compile error
Runtime Error
No error but goes to infinite loop

Q14: JVM stands for–
Java Vision Mechanism
Java Virtual Machine
Java Virtual Model
Java Vertical Model

Q15: Java consists of a ready-made package called–
Java Program
Java Applet
Java API
Java Widgets

Q16: Java Platforms consists of —
Java Program and Applet
Java API and JVM
Java Widgets and Programmes
Java Virtual Machine and Applets

Q17: Which of the following are not logical operators?
>>
&&
!
^

Q18: Java was developed by–
Microsoft
Sun Microsystems
Borland
Siemens

Q19: Which of the following variable is valid in Java?
variable1
variable2_n
variable=
variable 4

Q20: What is the result of the following operation?
System.out.println (4 / 3)
6
0
1
7

Q21: 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

Q22: In java ________ is the top hierarchy of the classes.
Class Name
Object
Main Method
Super Class

Q23: 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

Q24: 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

Q25: The keyword enewf 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

Q26: What are the five layouts of AWT?
a) BagGridLayout
b) FlowLayout
c) GridLayout
d) BagLayout
e) GridBagLayout
f) CardLayout
g) BorderLayout
b c e f g
a b c d e
f g e d a
a c b g e

Q27: Events do not respond to–
Physical Action
Logical Action
Astrological Action
All of the above

Q28: Checkbox, Menu item, and choice Listfs event can be handled by —
Adjustment Listener
Item Listener
Action Listener
Text Listener

Q29: Signature of the method includes–
Name of the Method
List of parameters
Return type of the method
Only a) and b)

Q30: 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

Q31: Constructor method will be created–
While compiling
While executing
When object is created
When class is created

Q32: Expansion of DNS is–
Distributed Name Service
Domain Name System
Domain Name Service
ðP
ðQ
ðN ðO
Domain Navigation Service

Q33: 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

Q34: 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

Q35: What tags are mandatory in HTML to display an applet?
Name, Height, Width
Codebase, Height, Width
Code, height, Width
Code

Q36: 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

Q37: The type of Java programs are–
Applications
Applets
Servlets
Packages

Q38: What do you mean by ‘eliteral’ 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

Q39: 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

Q40: 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