programming languages Online Quiz - 323
Description: programming languages Online Quiz - 323 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: programming languages |
What is the output of the following code when compiled and run? Select one correct answer. public class Question02 { public static void main(String[] args){ int j = 017; int i = (byte)j >> 2; //line 1 System.out.println(Integer.toBinaryString(i)); //line 2 } }
What is the output of the following code when compiled and run? Select one correct answer. import java.io.*; public class Question05 { public static void main(String[] args) { Question05Sub myref = new Question05Sub(); try{ myref.test(); }catch(IOException ioe){} } void test() throws IOException{ System.out.println("In Question05"); throw new IOException(); } } class Question05Sub extends Question05 { void test() { System.out.println("In Question05Sub"); } }
Select three correct statements about the following code. public class Question20 { public static void main(String[] args) { Question20 myref = new Question20Sub(); try{ myref.test(); }catch(Exception e){} } void test() throws Exception{ System.out.println("In Question20"); throw new Exception(); } } class Question20Sub extends Question20 { void test() { System.out.println("In Question20Sub"); } }
What is the output of the following code when compiled and run? Select one correct answer. public class Question41{ public static void main(String[] args){ Object[] obj = new Object[3]; for(int i=0;i
When an instance of a class, or object, is specified as a parameter to a method, a reference to the said object is passed to the method.
All interface methods must be declared as public when implemented in a class.
A method in a class declared as static may be invoked simply by using the name of the method alone.
A static method can refer to any instance variable of the class.
Each method in a class must have a unique name.
- Given a one dimensional array arr, what is the correct way of getting the number of elements in arr. Select the one correct answer.
- Which of these statements are legal. Select the three correct answers.
- Select all correct declarations, or declaration and initializations of an array?
4 Which of the following are the java keywords?
5 What will be printed when you execute the code? class A { A() { System.out.println("Class A Constructor"); } } public class B extends A { B() { System.out.println("Class B Constructor"); } public static void main(String args[]) { B b = new B(); } }
6 What will happen when you compile the following code? 1. package sources; 2. public class firstjava { 3. public static void main(String args[]) 4. { 5. private int a[] ={ 4, 4 }; 6. public int b=1; 7. a[b]=b=0; 8. System.out.println("value of b & a[0] & a[1]" + b + a[0] +a[1]); 9. } 10. }
7 What will be the result of attempting to compile and run the following code? abstract class MineBase { abstract void amethod(); static int i; } public class Mine extends MineBase { public static void main(String argv[]){ int[] ar=new int[5]; for(i=0;i < ar.length;i++) System.out.println(ar[i]); } }
9 If you run the code below, what gets printed out? String s=new String("Bicycle"); int iBegin=1; char iEnd=3; System.out.println(s.substring(iBegin,iEnd));
10 What modifiers would be legal at XX in the following code? public class MyClass1 { public static void main(String argv[]){ } /*Modifier at XX */ class MyInner {} }
11 What will the following code print out? public class Oct{ public static void main(String argv[]){ Oct o = new Oct(); o.amethod(); } public void amethod(){ int oi= 012; System.out.println(oi); } }