programming languages Online Quiz - 193
Description: programming languages Online Quiz - 193 | |
Number of Questions: 20 | |
Created by: Aliensbrain Bot | |
Tags: programming languages |
Given:
1. enum A { A }
2. class E2 {
3. enum B { B }
4. void C() {
5. enum D { D }
6. }
7. }
Which statements are true? (Choose all that apply.)
package testing; public class SimpleClone implements Cloneable { int number = 100; int[] intArray = new int[10]; public SimpleClone() { int number = 100; for (int i = 0; i < intArray.length; i++) { intArray[i] = number; number++; } } public static void main(String[] args) { SimpleClone testclone1 = new SimpleClone(); SimpleClone testclone2; try { testclone2 = (SimpleClone) testclone1.clone(); testclone1.intArray[0] = 1200; testclone2.intArray[0] = 1400; testclone1.number = 1200; System.out.print(" testclone1 intArray[0] = " + testclone1.intArray[0]); System.out.print(" testclone1one2 intArray[0] = " + testclone2.intArray[0]); System.out.print(" testclone1 value of number = " + testclone1.number); System.out.print(" testclone2 value of number = " + testclone2.number); } catch (CloneNotSupportedException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }
package io; import java.io.*; public class TestFile1 { public static void main(String[] args) { //No file exists by the name test_file.txt File file = new File("test_file.txt"); System.out.print(" Fle Name = "+file.getName()); System.out.print(" File Status = "+file.exists()); } }
package inheritance; class X { Y b = new Y(); X() { System.out.print("X"); } } class Y { Y() { System.out.print("Y"); } } public class Z extends X { Y y = new Y(); Z() { System.out.print("Z"); } public static void main(String[] args) { new Z(); } }
Signature has to be the same for overloading.
Overriding is an example of runtime polymorphism.
Unreachable statements produce a compile-time error.
Integer division by zero throws an exception.
package simplejava; public class TestConstructor2 { int p; TestConstructor2() { System.out.print(" I am in Constructor"); } TestConstructor2(int p) { this(); this.p = p; System.out.print(" p = " + p); } public static void main(String[] args) { TestConstructor2 tp1 = new TestConstructor2(10); } }
package simplejava;public class TestMain { TestMain() { System.out.println("I am in Constructor"); } TestMain(String message) { System.out.println("Message " + message); } public static void main(String[] args) { TestMain tm = new TestMain(); } public static void main(String args) { TestMain tm = new TestMain("Hello"); }}
package simplejava;public class TestMain1 { TestMain1() { System.out.println("I am in Constructor"); } TestMain1(String message) { System.out.println("Message " + message); } public void main(String[] args) { TestMain1 nm = new TestMain1(); TestMain1 nm1 = new TestMain1("Hello"); }}
Are you allowed to have more than one top-level(non-inner) class definition per source file?
Assume the bit pattern of byte x is: 10110001. What will the sign of x be after x>>2?
A class can define two methods with the same name as long as the return types are different
All exceptions inherit from