| |
Java Fundamental Q1. Which of the following are valid
definitions of an application’s main( ) method?
2. If MyProg.java were compiled as an
what would be the value of args[ 1 ] inside
3. Consider this class example: class MyPoint { void myMethod() { int x, y; x = 5; y = 3; System.out.print( " ( " + x + ", " + y + " ) " );switchCoords( x, y ); ///PASS BY VALUE SO NO CHANGE IN MAIN 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() 4. Consider the code below: public static void main( String args[] ) { int a = 5; System.out.println( cube( a ) );} int cube( int theNum ) ///CUBE IS NON STATIC…TRY…CREATE A CLASS USE CUBE() IN THAT CLASS…CREATE OBJECT OF THAT CLASS…NOW TRY IT..{ return theNum * theNum * theNum;} What will happen when you attempt to compile and run this code? 5. If val = 1 in the code below: Which values would be printed? 6. What is the parameter specification for the public static void main method?
Select all correct answers. 7. What will be the result of compiling the following code:
public class Test { public static void main (String args []) { int age; ///LOCAL VARIABLE///NEEDS 2 B INITIALIED age = age + 1; System.out.println("The age is " + age); } }
8. Which of the following is illegal:
9. What will be the result of compiling the following code:
public class Test { static int age; public static void main (String args []) { age = age + 1; System.out.println("The age is " + age); } }
10. Which of the following are so called "short circuit" logical operators?
|