Java, Programming Language Online Test

Which of the following statements will give the output as -4.0
System.out.println(Math.floor(-4.7)); 
System.out.println(Math.round(-4.7)); 
System.out.println(Math.ceil(-4.7)); 
System.out.println(Math.min(-4.7));
An Applet’s Layout Manager has a default value of FlowLayout. Which of the following is correct to set it to another Layout Manager.
setLayoutManager(new GridLayout()); 
setLayout(new GridLayout(2,2)); 
setGridLayout(2,2);
setBorderLayout();
For a class defined inside a method, what rule governs access to the variables of the enclosing method?
The class can access any variable
The class can only access static variables
The class can only access transient variables
The class can only access final variables
What will happen if you try to compile and run the following code public class MyClass { public static void main(String arguments[]) { amethod(arguments); } public void amethod(String[] arguments) { System.out.println(arguments); System.out.println(arguments[1]); } }
amethod must be declared with String
error array must include parameter
error method main not correct
error Can't make static reference to void amethod
Which method identifies the type of an event generated. Select the one correct answer.
getType()
getID()
getSource()
getEventType()
The default horizontal and vertical gap in FlowLayout is
0 pixel
10 pixels
1 pixel
5 pixels
What will happen when you attempt to compile and run the following code? public class Tux extends Thread{ static String sName = "vandeleur"; public static void main(String argv[]){ Tux t = new Tux(); t.piggy(sName); System.out.println(sName); } public void piggy(String sName){ sName = sName + " wiggy"; start(); } public void run(){ for(int i=0;i < 4; i++){ sName = sName + " " + i; } }
Compile time error
Compilation and output of either "vandeleur", "vandeleur 0", "vandeleur 0 1" "vandaleur 0 1 2" or "vandaleur 0 1 2 3"
Compilation and output of "vandeleur wiggy 0 1 2 3"
Compilation and output of "vandeleur wiggy"
Which of these are interfaces in the collection framework
LinkedList
List
Vector
Set
Array
public class MyClass1 { public static void main(String argv[]){ } /*Modifier at XX */ class MyInner {} } Which modifier would be illegal at XX in the above code?
static
private
friend
public
Which of these listner classes have corresponding adapter classes
ContainerListner
MouseMotionevent
TextListner
ItemListner
If you wanted to find out where the position of the letter v (ie return 2) in the string s containing "Java", which of the following could you use?
charAt(3) ;
charAt(2) ;
mid(2,s);
s.indexOf('v');
indexOf(s,'v');
Which of the following cannot be performed using the File class?
Return the name of the parent directory
Find if a file contains text or binary information
Delete a file
All the above
What will be printed out if you attempt to compile and run the following code? int i=9; switch (i) { default: System.out.println("default"); case 0: System.out.println("zero"); break; case 1: System.out.println("one"); case 2: System.out.println("two"); }
Error default clause not defined
no output displayed
default zero
Default
The method setLabel can be used with what type of Object?
String
DoubleField
Int
TextField
Which of the following will give compilation error
import java.awt.*; package Mypackage; class Myclass {}
package MyPackage; import java.awt.*; class MyClass{}
/*This is a comment */ package MyPackage; import java.awt.*; class MyClass{}
All will Compile
Trying determine the shape of a cylindrical can made from 1000 cm2 of tin that has the largest possible volume is an example of:
Optimization problem
Array calculation
Object oriented programming
Text manipulation
Which of the following statement is not true?
System.out.println( -1 >>> 2);will output a result larger than 10
System.out.println( -1 >>> 2); will output a positive number
System.out.println( 2 >> 1); will output the number 1
System.out.println( 1 <<< 2); will output the number 4
You are using the GridBagLayout manager to place a series of buttons on a Frame. You want to make the size of one of the buttons bigger than the text it contains. Which of the following will allow you to do that?
The GridBagLayout manager does not allow you to do this
The fill field of the GridBagConstraints class
The setFill method of the GridBagLayout class
The setFill method of the GridBagConstraints class
What is the return type of the method getID() defined in AWTEvent class
short
long
int
Object
Component
Description:

This is a 19-questions Test on JAVA
Disclaimer: Content, such as images used in the questions (if any), have been picked up from various places for the sole purpose of Instruction.

Discussion

prema vishnoi

good concept of core java programming Language

3197 days 14 hours 19 minutes ago

Your Facebook Friends on WizIQ

More Tests By Author

ASP Server Controls
10 Questions | 667 Attempts

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

An ASP.NET Application
10 Questions | 437 Attempts