1. Which of the following are valid definitions of an application's main( ) method?
a) public static void main(); b) public static void main( String args ); c) public static void main( String args[] ); d) public static void main( Graphics g ); e) public static boolean main( String args[] );
2. If MyProg.java were compiled as an application and then run from the command line as: java MyProg I like tests what would be the value of args[ 1 ] inside the main( ) method?
a) MyProg b) "I" c) "like" d) 3 e) 4 f) null until a value is assigned
3. Which of the following are Java keywords?
a) array b) boolean c) Integer d) protect e) super
4. After the declaration: char[] c = new char[100]; what is the value of c[50]?
a) 50 b) 49 c) '\u0000' d) '\u0020' e) " " f) cannot be determined g) always null until a value is assigned
5. After the declaration: int x; the range of x is:
a) -231 to 231-1 b) -216 to 216 - 1 c) -232 to 232 d) -216 to 216 e) cannot be determined; it depends on the machine
6. Which identifiers are valid?
a) _xpoints b) r2d2 c) bBb$ d) set-flow e) thisisCrazy
7. Represent the number 6 as a hexadecimal literal.
8. Which of the following statements assigns "Hello Java" to the String variable s?
a) String s = "Hello Java"; b) String s[] = "Hello Java"; c) new String s = "Hello Java"; d) String s = new String("Hello Java");
9. An integer, x has a binary value (using 1 byte) of 10011100. What is the binary value of z after these statements: int y = 1 << 7; int z = x & y;
a) 1000 0001 b) 1000 0000 c) 0000 0001 d) 1001 1101 e) 1001 1100
10. Which statements are accurate:
a) >> performs signed shift while >>> performs an unsigned shift. b) >>> performs a signed shift while >> performs an unsigned shift. c) << performs a signed shift while <<< performs an insigned shift. d) <<< performs a signed shift while << performs an unsigned shift.
11. The statement ... String s = "Hello" + "Java"; yields the same value for s as ... String s = "Hello"; String s2= "Java"; s.concat( s2 ); True False
12. If you compile and execute an application with the following code in its main() method: String s = new String( "Computer" );
if( s == "Computer" ) System.out.println( "Equal A" ); if( s.equals( "Computer" ) ) System.out.println( "Equal B" ); a) It will not compile because the String class does not support the = = operator. b) It will compile and run, but nothing is printed. c) "Equal A" is the only thing that is printed. d) "Equal B" is the only thing that is printed. e) Both "Equal A" and "Equal B" are printed.
13. Consider the two statements: 1. boolean passingScore = false && grade == 70; 2. boolean passingScore = false & grade == 70; The expression grade == 70 is evaluated:
a) in both 1 and 2 b) in neither 1 nor 2 c) in 1 but not 2 d) in 2 but not 1 e) invalid because false should be FALSE
14. Given the variable declarations below: byte myByte; int myInt; long myLong; char myChar; float myFloat; double myDouble; Which one of the following assignments would need an explicit cast?
a) myInt = myByte; b) myInt = myLong; c) myByte = 3; d) myInt = myChar; e) myFloat = myDouble; f) myFloat = 3; g) myDouble = 3.0;
15. Consider this class example: class MyPoint { void myMethod() { int x, y; x = 5; y = 3; System.out.print( " ( " + x + ", " + y + " ) " ); switchCoords( x, y ); System.out.print( " ( " + x + ", " + y + " ) " ); } void switchCoords( int x, int y ) { int temp; temp = x; x = y; y = temp; System.out.print( " ( " + x + ", " + y + " ) " ); } } What is printed to standard output if myMethod() is executed?
a) (5, 3) (5, 3) (5, 3) b) (5, 3) (3, 5) (3, 5) c) (5, 3) (3, 5) (5, 3)
16. To declare an array of 31 floating point numbers representing snowfall for each day of March in Gnome, Alaska, which declarations would be valid?
a) double snow[] = new double[31]; b) double snow[31] = new array[31]; c) double snow[31] = new array; d) double[] snow = new double[31];
17. If arr[] contains only positive integer values, what does this function do? public int guessWhat( int arr[] ) { int x= 0; for( int i = 0; i < arr.length; i++ ) x = x < arr[i] ? arr[i] : x; return x; } a) Returns the index of the highest element in the array b) Returns true/false if there are any elements that repeat in the array c) Returns how many even numbers are in the array d) Returns the highest element in the array e) Returns the number of question marks in the array
18. Consider the code below: arr[0] = new int[4]; arr[1] = new int[3]; arr[2] = new int[2]; arr[3] = new int[1]; for( int n = 0; n < 4; n++ ) System.out.println( /* what goes here? */ ); Which statement below, when inserted as the body of the for loop, would print the number of values in each row?
a) arr[n].length(); b) arr.size; c) arr.size -1; d) arr[n][size]; e) arr[n].length;
java
java hi im new to java plz suggest me how to master java....saifjunaid@gmail.com
java
java dear,
i want a field for date picker using java/java script
java java online telephone directory i need coding for online telephone directory..by using java....pls help me
java
java how to edit text document by using java
then how to edit starting and ending of text document by using java
java java pattern code for a given words java pattern code for a given words pattern
java
java how can use sleep in java
which book learn of java language
java java How to set java Policy for applet using jdk 6
java
java create java program for delete and update the details,without using database, just a normal java program
java
java why methods in java raise exceptions
Have a look at the following link:
Java Exceptions
java java code to search the nodes how to write the java code to search the nodes using routers
java
java different between java & core java
print("code sample
java
java different between java & core java
print("code sample
java
java how to prepare the java
Hi Friend,
If you want to learn how to install java, creating and running a java program then go through the following links:
http://www.roseindia.net/java/beginners/index.shtml
http
java
java java swing
Swing is a principal GUI toolkit for the Java programming language. It is a part of the JFC (Java Foundation Classes), which is an API for providing a graphical user interface for Java programs
java
java what is the need of java if java is not there what will happen... work unless you have Java installed, and more are created every day. Java... to scientific supercomputers, cell phones to the Internet, Java is everywhere!
http
java
java 1.what type of inheritance supported in java.
2.what is the advantage of java over C++.
Hi Friend,
Java supports following... inheritance
Advantages of Java over C++:
1)Java is pure object oriented
java
java how to run applets in java
Hi,
In Java you can use Applet viewer to run the applet. Read more at Java Applet Viewer tutorial page.
Thanks
java
java what is javaJava is a programming language..., and business applications.
Advantages of Java:
* Java is simple, easy to design... programming languages.
* Java is object-oriented, that is used to build modular
Java Java What is the immediate superclass of the Dialog class