Block scope , Casts class Conversion & Demonstrate an inner class online Test

Which is a method of the MouseMotionListener interface?
Public void mouseMoved(MouseEvent)
Public boolean mouseMoved(MouseEvent)
Public void mouseMoved(MouseMotionEvent)
Public boolean MouseMoved(MouseMotionEvent
You are assigned the task of building a panel containing a TextArea at the top, a label directly below it, and a button directly below the label. If the three components are added directly to the panel, which layout manager can the panel use to ensure that the TextArea absorbs all of the free vertical space when the panel is resized?
CardLayout
FlowLayout
BorderLayout
GridBagLayout
------------------is the mechanism that binds together code and the data it manipulates, and keeps both safe from outside interference and misuse.
Encapsulation
polymorphism
Information hiding
Inheritance
------------------is the process by which one object acquires the properties of another object. This is important because it supports the concept of hierarchical classification.
Encapsulation
polymorphism
Information hiding
Inheritance
In Java, there are a few characters that are used as separators. The most commonly used separator in Java is the semicolon. As you have seen, it is used to terminate statements. The separators are shown in the following table: Symbol Name Purpose ( ) Parentheses Used to contain lists of parameters in method definition and invocation. Also used for defining precedence in expressions, containing expressions in control statements, and surrounding cast types. { } Braces Used to contain the values of automatically initialized arrays. Also used to define a block of code, for classes, methods, and local scopes. / / two forward slashs Used to declare array types. Also used when dereferencing array values. ; Semicolon Terminates statements. , Comma Separates consecutive identifiers in a variable declaration. Also used to chain statements together inside a for statement. . Period Used to separate package names from subpackages and classes. Also used to separate a variable or method from a reference variable. In the above statements which is wrong?
( ) Parentheses Used to contain lists of parameters in method definition and invocation. Also used for defining precedence in expressions, containing expressions in control statements, and surrounding cast types.
/ / two forward slashs Used to declare array types. Also used when dereferencing array values.
Period Used to separate package names from subpackages and classes. Also used to separate a variable or method from a reference variable.
; Semicolon Terminates statements.
In addition to the keywords, Java reserves the following: These are values defined by Java.
true
false
null
All of the above
class CharDemo2 { public static void main(String args[]) { char ch1; ch1 = 'X'; System.out.println("ch1 contains " + ch1); ch1++; // increment ch1 System.out.println("ch1 is now " + ch1); } } The output generated by this program is shown AS :
ch1 contains Y ch1 is now X
ch1 contains X ch1 is now Y
ch1 contains X ch1 is now Z
ch1 contains Z ch1 is now Y
Demonstrate block scope. class Scope { public static void main(String args[]) { int x; // known to all code within main x = 10; if(x == 10) { // start new scope1 THE JAVA LANGUAGE int y = 20; // known only to this block // x and y both known here. System.out.println("x and y: " + x + " " + y); x = y * 2; } // y = 100; // Error! y not known here // x is still known here. System.out.println("x is " + x); } } In the above program what what will be the out put in scope1 ?
x and y: 10 20
x and y: 11 21
x and y: 12 22
x and y: 9 19
// Demonstrate casts. class Conversion { public static void main(String args[]) { byte b; int i = 257; double d = 323.142; System.out.println("\nConversion of int to byte."); b = (byte) i; System.out.println("i and b " + i + " " + b); System.out.println("\nConversion of double to int."); i = (int) d; System.out.println("d and i " + d + " " + i); System.out.println("\nConversion of double to byte."); b = (byte) d; System.out.println("d and b " + d + " " + b); } } What is the output of the above program?
Conversion of int to byte. i and b 257 1 Conversion of double to int. d and i 323.142 323 Conversion of double to byte. d and b 323.142 67
Conversion of int to byte. i and b 257 2 Conversion of double to int. d and i 323.142 323 Conversion of double to byte. d and b 323.142 67
class Matrix { public static void main(String args[]) { double m[][] = { { 0*0, 1*0, 2*0, 3*0 }, { 0*1, 1*1, 2*1, 3*1 }, { 0*2, 1*2, 2*2, 3*2 }, { 0*3, 1*3, 2*3, 3*3 } }; int i, j; for(i=0; i<4; i++) { for(j=0; j<4; j++) System.out.print(m[i][j] + " "); System.out.println(); } } } THE JAVA When you run this program, you will get the following output:
0.0 0.0 0.0 0.0 0.0 1.0 2.0 3.0 0.0 2.0 4.0 6.0 0.0 3.0 6.0 9.0
0 0 0 0 0 1 2 3 0 2 4 6 0 3 6 9
0.00 0.00 0.00 0.00 0.00 1.00 2.0 3.0 0.0 2.0 4.0 6.0 0.0 3.0 6.0 9.0
None of the above
String str = "this is a test"; System.out.println(str); What will be the out of the above statement?
“ this is a test ”.
“ this is a test ”.
this is a test.
None of the above
Demonstrate ++. class IncDec { public static void main(String args[]) { int a = 1; int b = 2; int c; int d; c = ++b; d = a++; c++; System.out.println("a = " + a); System.out.println("b = " + b); System.out.println("c = " + c); System.out.println("d = " + d); } } What will be the out put of the above program ?
a = 1 b = 2 c = 3 d = 4
a = 2 b = 3 c = 5 d = 1
a = 2 b = 3 c = 4 d = 5
a = 2 b = 3 c = 4 d = 1
Using break with nested loops. class BreakLoop3 { public static void main(String args[]) { for(int i=0; i<3; i++) { System.out.print("Pass " + i + ": "); for(int j=0; j<100; j++) { if(j == 10) break; // terminate loop if j is 10 System.out.print(j + " "); } System.out.println(); } System.out.println("Loops complete."); } } What is the outut of the above program?
Pass 0: 0 1 2 3 4 5 6 7 8 9 Pass 1: 0 1 2 3 4 5 6 7 8 9 Pass 2: 1 2 3 4 5 6 7 8 9 10 Loops complete.
Pass 0: 0 1 2 3 4 5 6 7 8 9 Pass 1: 1 2 3 4 5 6 7 8 9 10 Pass 2: 0 1 2 3 4 5 6 7 8 9 Loops complete.
Pass 0: 0 1 2 3 4 5 6 7 8 9 Pass 1: 0 1 2 3 4 5 6 7 8 9 Pass 2: 0 1 2 3 4 5 6 7 8 9 Loops complete.
None of the above
LAUGE class Continue { public static void main(String args[]) { for(int i=0; i<10; i++) { System.out.print(i + " "); if (i%2 == 0) continue; System.out.println(""); } } }
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
0 1 2 3 4 5 6 7 8 9
None of the above
Using continue with a label. class ContinueLabel { public static void main(String args[]) { outer: for (int i=0; i<10; i++) { for(int j=0; j<10; j++) { if(j > i) { System.out.println(); continue outer; } System.out.print(" " + (i * j)); } } System.out.println(); } } What is the out put of the above program ?
CORE JAVA
class Box { double width; double height; double depth; } class BoxDemo2 { public static void main(String args[]) { Box mybox1 = new Box(); Box mybox2 = new Box(); LANGUAGE double vol; // assign values to mybox1's instance variables mybox1.width = 10; mybox1.height = 20; mybox1.depth = 15; /* assign different values to mybox2's instance variables */ mybox2.width = 3; mybox2.height = 6; mybox2.depth = 9; // compute volume of first box vol = mybox1.width * mybox1.height * mybox1.depth; System.out.println("Volume is " + vol); // compute volume of second box vol = mybox2.width * mybox2.height * mybox2.depth; System.out.println("Volume is " + vol); } } What is the out put of the above program?
Volume is 300.0 Volume is 162.0
Volume is 3000.0 Volume is 162.0
Volume is 3000.0 Volume is 16.0
// Now, volume() returns the volume of a box. class Box { double width; double height; double depth; // compute and return volume double volume() { return width * height * depth; } } class BoxDemo4 { public static void main(String args[]) { Box mybox1 = new Box(); Box mybox2 = new Box(); double vol; // assign values to mybox1's instance variables mybox1.width = 10; mybox1.height = 20; mybox1.depth = 15; /* assign different values to mybox2's instance variables */ mybox2.width = 3; mybox2.height = 6; mybox2.depth = 9; // get volume of first box vol = mybox1.volume(); System.out.println("Volume is " + vol); // get volume of second box vol = mybox2.volume(); System.out.println("Volume is " + vol); } } In the above program what the return statement will do?
It returns width * height * depth value to method volume().
It returns width * height * depth value to main().
It returns width * height * depth value to object.
It returns width * height * depth value to class.
// Demonstrate an inner class. class Outer { int outer_x = 100; void test() { Inner inner = new Inner(); inner.display(); } // this is an inner class class Inner { void display() { System.out.println("display: outer_x = " + outer_x); } } } class InnerClassDemo { public static void main(String args[]) { Outer outer = new Outer(); outer.test(); } } What is the output of the above program ?
display: outer_x = 100
display: outer_x = 10
display: outer_x = 1000
None of the above
Users’ browser settings will override the settings you make in your style sheets by default. It is easy for users to change the fonts, background colors, and size of the text. Users can also choose to turn off functionality such as Java, JavaScript, and image display.
False
True
Which web technology with its appropriate task is used to Checks a form field for a , valid entry
HTML and XHTML
CSS
Ruby on Rails
JavaScript
To use JavaScript in your Web page, define a few functions and commands at the beginning of your HTML code (before the closing tag)
True
False
Description:

Basically this test contains 20 questions to check your knowledge on the block scope, casts conversion and inner classes.
Disclaimer: Content, such as images used in the questions (if any), have been picked up from various places for the sole purpose of Instruction.

Comments
Alexandra
By: Alexandra
1353 days 16 hours ago

HELLO to every body, the exam's content doesn't display.

Want to learn?

Sign up and browse through relevant courses.

or fill this simple form
Name:
Your Email:
Password:
Country:
Contact no.:


Area code Number
Subjects you are interested in:
Word verification: (Enter the text as shown in image)


Sign Up Already a member? Sign In
I agree to WizIQ's User Agreement & Privacy Policy

Your Facebook Friends on WizIQ

More Tests By Author

ASP Server Controls
10 Questions | 420 Attempts

ASP.NET, Namespaces ASP.NET
10 Questions | 1456 Attempts

An ASP.NET Application
10 Questions | 284 Attempts

Test your basic knowledge on DATASTRUCTURES, STACK
10 Questions | 953 Attempts

Connect