Java Exam (2)

xiaoxiao2021-03-06  21

Module 1 - Getting Started

Q1.WHAT WILL HAPPEN WHEN YOU COMPILE AND RUN THE FOLLOWING CODE?

Public class myclass {

Static Int i;

Public static void main (String Argv []) {

System.out.println (i);

}

}

1) Error Variable I May Not Have Been Initialized 2) NULL 3) 1 4) 0

Q2.Which of the Following Will Compile without Error

1)

Import java.awt. *;

Package mypackage;

Class myclass {}

2)

Package mypackage;

Import java.awt. *;

Class myclass {}

3)

/ * This is a comment * /

Package mypackage;

Import java.awt. *;

Class myclass {}

Q3.What will happen if you try to compile and rain 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]);

}

}

1) Error can't make static reference to void amethod. 2) Error Method Main Not Correct 3) Error Array Must Include Parameter 4) AMETHOD MUST BE DECLARED with STRING

Q4.given The Following Code

Public class sytch {

INT x = 2000;

Public static void main (String Argv []) {

System.out.println ("MS" Argv [1] "please pay $" x);

}

}

What Will Happen if you attempt to compile and run this code with the command line

Java Sytch Jones Diggle

1) Compilation and Output of MS Diggle Please Pay $ 20002) Compilation and Output of MS Jones Please Pay $ 20004) CompiLation But Runtime Error

Q5.You Have a public class caled myclass with the main method defined as Follows

Public static void main (String Parm []) {

System.out.println (PARM [0]);

}

IF you attempt to compile the class and rain the program as Follows

Java myclass hello

What Will Happen?

1) Compile time error, main is not correctly defined2) Run time error, main is not correctly defined3) Compilation and output of java4) Compilation and output of helloModule 2 Identifiers, Keywords, and Types

Q1.Which of The Following Are Legal Statements?

1) float f = 1/3; 2) INT i = 1/3; 3) float f = 1.01; 4) Double D = 999d;

Q2.Which of The Following Are Java Keywords?

1) NULL2) New3) Instanceof4) Wend

Q3.Which of The Following Are Java Keywords?

1) SIZEOF2) Main3) Transient4) Volatile

Q4.given the folowing declaration

Integer i = new integer (99);

How can you now set the value of i to 10?

1) i = 10; 2) I.SetValue (10); 3) I.PARSEINT (10); 4) None of the Above

Q5.Which of the Following Will Compile Correctly

1) Short myshort = 99s; 2) String name = 'Excellent Tutorial Mr Green'; 3) CHAR C = 17c; 4) INT Z = 015;

Q6.Which of The Following Are Java Key Words1) Double2) Switch3) THEN4) InstanceOf

Q7.Which of the folowing lines will compile without warning or error.

1) float f = 1.3; 2) CHAR C = "a"; 3) BYTE B = 257; 4) Boolean B = NULL; 5) INT I = 10;

Q8.A Byte Can Be of What size

1) -128 to 127 2) (-2 Power 8) -1 to 2 Power 8 3) -255 TO 256 4) Depends on the particular implementation of the java virtual machineine

Q9.Which of The Following Area Keywords Or Reserved Words in java?

1) IF 2) THEN 3) GOTO 4) WHILE 5) CASE

Q10.Which of the folloading area Legal IdentifierS

1) 2Variable 2) Variable2 3) _Whatavariable 4) _3_5) $ anothervar 6) #myvar

Module 4 - Arrays

Q1.WHAT code placed after the comment // for loop Would Result in the population of every of the array ia [] with a value from variable i.?

Public class lin {

Public static void main (String Argv []) {

LIN L = New Lin (); L.AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You want to find out the value of the last element of an array. You Write the Following Code. What Will Happen When You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q5.Which of The Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method

Module 4 - Arrays

Q1.What code placed after the comment // for loop Would Result in the population of every equipment of the array ia [] with a value from variable i.?public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You want to find out the value of the last element of an array. You Write the Following Code. What Will Happen When You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q5.Which of The Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method 4 - arrays

Q1.WHAT code placed after the comment // for loop Would Result in the population of every of the array ia [] with a value from variable i.?

Public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You want to find out the value of the last element of an array. You Write the Following Code. What Will Happen When You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at compile3) The value 0 Will Be Output4) The string "Null" Will Be Outputq5.Which of the Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method

Module 3 - Expressions and Flow Control

Q1.WHAT WILL BE PRINTED OUT IF You Attempt To Compile and Run THE FOLLOWING CODE?

INT i = 1;

Switch (i) {

Case 0:

System.out.println ("Zero");

Break;

Case 1:

System.out.println ("One");

Case 2:

System.out.println ("Two");

DEFAULT:

System.out.println ("Default");

}

1) One 2) One, Default 3) One, Two, Default 4) DEFAULT

Q2.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");

}

1) DEFAULT 2) Default, Zero 3) Error Default Clause Not Defeed 4) No Output Displayed

Q3.Which of the Following Lines of code Will Compile With Error

1)

INT i = 0;

IF (i) {

System.out.Println ("Hello");

}

2)

Boolean b = true;

Boolean B2 = True;

IF (b == b2) {

System.out.println ("so true");

}

3)

INT i = 1;

INT J = 2;

IF (i == 1 || j == 2)

System.out.println ("OK");

4)

INT i = 1;

INT J = 2;

IF (i == 1 & | j == 2)

System.out.println ("OK");

Q4.Which of The Following Statements Are True? 1) System.out.println (-1 >>> 2); Will Output A Result Larger Than 102) System.out.Println (-1 >>> 2); Will Output A Positive Number 3) System.out.Println (2 >> 1); Will Output The Number 1 4) System.out.println (1 <<< 2); Will Output The Number 4

Q5.WHAT WILL HAPPEN IF you attempt to compile and weight? FOLLOWING CODE?

Integer ten = new integer (10);

Long nine = new long (9);

System.out.println (Ten Nine);

INT i = 1;

System.out.println (i ten);

1) 19 Followed by 20 2) 19 Followed by 11 3) Compile Time Error 4) 10 FOLLOWED BY 1

Given the folowing declarations

String S1 = New String ("Hello")

String s2 = new string ("there");

String s3 = new string ();

Q6.Which of The Following Are Legal Operations?

1) S3 = S1 S2; 2) S3 = S1-S2; 3) S3 = S1 & S2; 4) S3 = S1 && S2

Q7.What is the result of the folowing operation?

System.out.println (4 | 3);

1) 6 2) 0 3) 1 4) 7

Q8.What will happen when you attempt to compile and rain the following code

Public class myswitch {

Public static void main (String Argv []) {

MySwitch MS = new myswitch ();

Ms.amethod ();

}

Public void amethod () {

INT K = 10;

Switch (k) {

Default: // Put The Default At the Bottom, Not Here

System.out.println ("this is the default output";

Break;

Case 10:

System.out.println ("Ten");

Case 20:

System.out.println ("twenty");

Break;

}

}

}

1) None of these options2) Compile and Run with output "this is the default output" 4) compile and run "4) Compile and run" ten "

Q9.WHAT WILL HAPPEN WHEN You Attempt to Compile And Run The Following Codeint Output = 10;

Boolean B1 = FALSE;

IF ((b1 == true) && ((Output = 10) == 20)) {

System.out.println ("We Are Equal" Output;

Else

{

System.out.println ("NOT Equal!" Output;

}

1) Compile Error, Attempting to Peform Binary Compilation and ON Logical Data Type2) Compilation and Output of "We Are Equal 10" 3) Compilation and Output of "NOT Equal! 20" 4) Compilation and Output of "Not Equal! 10"

Q10.GIVEN THE FOLLOWING VARIABLES Which of the FOLLOWING LINES WILL COMPILE WITHOUT ERROR?

String s = "hello";

Long L = 99;

Double D = 1.11;

INT i = 1;

INT j = 0;

1) j = i << s;

2) j = i << j;

3) j = i << d;

4) j = i << l;

Q11.What Will Be Output by The Following Line of Code?

System.out.println (010 | 4);

1) 142) 03) 64) 12

Given the Following Variables

CHAR C = 'c';

INT i = 10;

Double D = 10;

Long L = 1;

String s = "hello";

Q12.Which of the Following Will Compile WITHOUT ERROR?

1) C = C I; 2) S = I; 3) i = S; 4) C = S;

Q13.Which of The Following Will Compile WITHOUT ERROR?

1)

CHAR C = '1'; System.out.Println (C >> 1);

2)

Integer i = integer ("1"); system.out.println (i >> 1);

3)

INT i = 1; system.out.println (i <<< 1);

4)

INT i = 1; System.out.Println (i << 1);

Q14.Which of The Following Statements Are True?

1) The String class is implemented as a char array, elements are addressed using the stringname [] convention2) The operator is overloaded for concatenation for the String class3) Strings are a primitive type in Java and the StringBuffer is used as the matching wrapper TYPE4) THE SIZE OF A STRING CAN Be Retrieved Using The Length Propertyq15.Which of The Following Statements Are True?

1) The following statement will produce a result of 1. System.out.println (-1 >>> 2); 2) Performing an unsigned left shift (<<<) on a negative number will always produce a negative number result3) The Following Statement Will Produce A Result of Zero, System.out.Println (1 >> 1); 4) All The Java Integral Types Are Signed Numbers

Q16. Given The Following Class

Public class omb isolaley {

Public static void main (String Argv []) {

Boolean B1 = True;

IF ((B1 == True) || Place (TRUE)) {

System.out.println ("Hello Crowle");

}

}

Public Static Boolean Place (Boolean Location) {

IF (location == true) {

System.out.println ("borcetshire");

}

System.out.println ("Powick");

Return True;

}

}

What WILL HAPPEN WHEN You Attempt To Compile and Run IT?

1) Compile Time error2) Output of "Hello Crowle" 3) Output of borcetshire and power "Hello Crowle" 4) No Output

Q17. Which of the folloading statements are TRUE?

1) THE% IS Used to Calculate a Percentage Thus: 10% 20 = 502) The / Operator IS Used to Divide One Value By Another3) The # symbol May Not Be Used As The First Character of a Variable4) The $ SYMBOL MAY NOT Be buy as the first character of a variable

Q18.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Code?

PUBLIC Class Agg {

Static public long i = 10; public static void main (string argv []) {

Switch (i) {

DEFAULT:

System.out.println ("No Value Given");

Case 1:

System.out.println ("One");

Case 10:

System.out.println ("Ten");

Case 5:

System.out.println ("FIVE");

}

}

}

1) Compile Time Error2) Output of "Ten" FOLLOWED BY "3) Output of" Ten "4) Compilation and Run Time Error Because of Location of DEFAULT

Q19.What Will Happen when you attempt to compile and rain the following code

Public class streq {

Public static void main (String Argv []) {

Streq s = new streq ();

}

Private streq () {

String s = "marcus";

String S2 = New String ("marcus");

IF (s == s2) {

System.out.println ("We Have A Match");

} else {

System.out.println ("Not Equal");

}

}

}

1) Compile Time Error Caused by Private Constructor2) Output of "We Have A Match" 3) Output of "Not Equal" 4) Compile Time Error By Attempting to Compare Strings Using ==

Q20.given the following code, what test would you need to put in place of the comment line?

// Place Test Here

To Result in An Output of the string equal

Public class eqtest {

Public static void main (String Argv []) {

EQTEST E = New EQTEST ();

}

EQTEST () {

String s = "java";

String S2 = "java";

// Place test here {

System.out.println ("Equal");

Else

{

System.out.println ("Not Equal");

}

}

}

1) IF (S == S2) 2) IF (S.EqualsignoreCase (S2)) 4) IF (S.NocaseMatch (S2))

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return name;}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC ();

INT i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void AnotherMethod () {} Q6.Which of the Following Most Closely Describes the process of overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses For the Same Method Name4) a class is prevented from accessing methods in its immediate anncestor

Q7.Which of the folloading statements are TRUE?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {

Public static void main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following codeclass Base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile Time Error Base Is A Keyword2) Compilation and No Output At Runtime3) Output of Base4) Runtime Error Base Has No Valid Constructor

Q11.What will happen when you attempt to compile and rain the Following Code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addelement (99);

3) Vector v = new vector (); v.Add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (REF R) {R.I = R.I * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.given the following class definition Which of the folloading can be leGally Placed After the comment line //th?

Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void afancymethod () {

System.out.println ("What a Fancy Method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC (); int i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses FOR THE SAME MEVEND NAME4) A Class Is Prevented from Accessing Methods in ITS IMMEDIATE ANCESTORQ7.WHICH OF THE FOLLOWING STATEments Are True?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {

Public static void main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following code

Class base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile time error Base is a keyword2) Compilation and no output at runtime3) Output of Base4) Runtime error Base has no valid constructorQ11.What will happen when you attempt to compile and run the following code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addelement (99);

3) Vector v = new vector (); v.Add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (Ref r) {

R.I = r.i * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.given the following class definition Which of the folloading can be leGally Placed After the comment line //th?

Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public class rid {

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void AfancyMethod () {system.out.println ("what a fancy method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC ();

INT i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses For the Same Method Name4) a class is prevented from accessing methods in its immediate anncestor

Q7.Which of the folloading statements are TRUE?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {Public Static Void Main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following code

Class base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile Time Error Base Is A Keyword2) Compilation and No Output At Runtime3) Output of Base4) Runtime Error Base Has No Valid Constructor

Q11.What will happen when you attempt to compile and rain the Following Code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addeElement (99); 3) Vector v = new vector (); v.add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (Ref r) {

R.I = r.i * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.Given the following class definition which of the folloading can be legally placed after the comment line // here? Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public class rid {

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void afancymethod () {

System.out.println ("What a Fancy Method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 6 - Advanced Language FeaturesQ1.What will happen when you attempt to compile and run the following code.public class Pvf {static boolean Paddy; public static void main (String argv []) {System.out.println (Paddy);} } 1) Compile time error2) compilation and output of false3) compilation and output of true4) compilation and output of nullQ2.What will happen when you attempt to compile and run the following codeclass Base {protected int i = 99;} public class Ab {Private INT i = 1; public static void main (string argv []) {ab a = new ab (); a.hallow ();} Abstract void Hallow () {system.out.println ("Claines" i );}} 1) Compile time error2) Compilation and output of Claines 993) Compilation and output of Claines 14) Compilation and not output at runtimeQ3.Given the following codeclass Base {static int oak = 99;} public class Doverdale extends Base { Public static void main (string argv []) {DOVERDALE D = New Doverdale (); D. AMETHOD ();} public void AMETHOD () {// Here}} Which of the fol, means, will compile and model, will compile and modify the value of the variable oak? 1) Super.oak = 1; 2) Oak = 33; 3) Base .OAK = 22; 4) OAK = 50.1;

Q4.Which of the following statements are true? 1) A method in an interface must not have a body2) A class may extend one other class plus at most one interface3) A class may extends at most one other class plus implement many interfaces4) via class accesses an interface An the keyword usesQ5.Which of the following statements are true? 1) static methods do not have access to the implicit variable called this2) A static method may be called without creating an instance of its class3) A static method may not be overriden to be non-static4) A static method may not be overloadedQ6.Given the folowing classes which of the following will compile without error? interface iFace {} class CFace implements iFace {} class Base {} public class ObRef extends Base {Public static void main (string argv []) {obref ob = New obref (); base b = new base (); object o1 = new object (); ifce o2 = new cface ();}} 1) O1 = O2; 2) b = ob; 3) ob = B; 4) O1 = b; Q7.given the folowing codeclass base {} public cl Ass mycast extends base {static boolean b1 = false; static int i = -1; static double d = 10.1; public static void main (string argv []) {mycast m = new mycast (); base b = new base () ; // hRE}} which of the following, IF inserted at the code = m; 2) m = b; 3) D = i; 4) b1 = i; Q8.What will happen when you attempt to compile and run the following code with the command line "hello there" public class Arg {String [] MyArg; public static void main (String argv []) {MyArg = argv;} Public void amethod () {system.out.println (Argv [1]);

}} 1) Compile time error2) Compilation and output of "hello" 3) Compilation and output of "there" 4) None of the aboveQ9.What will happen when you attempt to compile and run this code? Class Base {abstract public void Myfunc (); public void another () {system.out.println ("another method");}}} public class abs Extends base {public static void main (string argv []) {ABS A = New ABS (); A Public void ();} public void myfunc () {system.out.println ("my func");} public void amethod () {myfunc ();}} 1) The code will compile and run, printing out the word "My Func" 2) The compiler will complain that the Base class is not declared as abstract.3) The code will compile but complain at run time that the Base class has non abstract methods4) The compiler will complain that the method myfunc in the Base Class Has NO Body, Nobody At All to Look ITQ10.WHAT WILL HAPPEN WHEN You Attempt To Compile and R ? Un this code abstract class Base {abstract public void myfunc (); public void another () {System.out.println ( "Another method");}} public class Abs extends Base {public static void main (String argv [] ) {ABS A = New ABS (); a.amethod ();} public void myfunc () {system.out.println ("my func");} public void amethod () {myfunc ();}} 1) The Code Will Compile and Run, Printing Out The Words "My FUNC"

2) The compiler will complain that the Base class has non abstract methods3) The code will compile but complain at run time that the Base class has non abstract methods4) The compiler will complain that the method myfunc in the base class has no body, nobody At all to loooove it q1.given the folowing code import java.io. *; public class ppvg {public static void main (string argv []) {ppvg p = new ppvg (); p.fliton ();} public int Fliton () {Try {fileInputStream DIN = New FileInputStream ("ppvg.java"); DIN.Read ();} catch (ioException ooe) {system.out.println ("flytwick"); return 99;} finally {system .out.println ( "fliton");} return -1;}} Assuming the file Ppvg.java is available to be read which of the following statements are true if you try to compile and run the program 1) The program will? Run and Output Only "Flytwick" 2) The Progr am will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because the method fliton attempts to return two valuesQ2.What will happen when you attempt to compile and run the following codeimport java.io *;. class Base {public void amethod () throws FileNotFoundException {}} public class ExcepDemo extends Base {public static void main (String argv []) {ExcepDemo e = new ExcepDemo () PUBLIC VOID AMETHOD () {} protected excepdemo () {Try {DataInputStream DIN = New DataInputStream (System.IN); System.Out.Println ("Pause");

din.readByte (); System.out.println ( "Continuing"); this.amethod ();} catch (IOException ioe) {}}} 1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hitQ3.You want to find out the value of the last element of an array. You write the following Code. What Will Happen When You Compile and Run It.?public Class Myar {Public Static Void Main (String Argv []) {Int [] i = new int [5]; system.out.println (i [5]) ;}} 1) An error at compile time2) An error at run time3) The value 0 will be output4) The string "null" will be outputQ4.Given the following code import java.io *;. public class Th {public static Void main (string argv []) {th t = new TH (); t.amethod ();} public void amethod () {i ocall ();} catch (IOException ioe) {}}} What code would be most likely for the body of the ioCall method 1) public void ioCall () throws IOException {DataInputStream din = new DataInputStream (System.in); din.readChar ();} 2 ) public void ioCall () throw IOException {DataInputStream din = new DataInputStream (System.in); din.readChar ();} 3) public void ioCall () {DataInputStream din = new DataInputStream (System.in); din.readChar ( } 4) Public void ocall throws ooException () {DATAINPUTSTREAM DIN = New DataInputStream (System.IN); DIN.READCHAR ();

} Q5.What will be output if you try to compile and run the following code, but there is no file called Hello.txt in the current directory ?. import java.io *;. Public class Mine {public static void main (String Argv []) {mine m = new mine (); system.out.println (m.amethod ());} public int athod () {Try {fileInputstream dis = new fileInputstream ("hello.txt");} catch (FilenotFoundException FNE) {system.out.println ("No Such file found"); return -1;} catch (ooException ooe) {} finally {system.out.println ("doing firmly");} return 0;} } 1) No Such Found, -1 3) No Such File Found, Doing Finally, -1 4) 0 Q1.given The Following Code Import Java.io. *; Public Class PPVG {Public Static Void Main (String Argv []) {PPVG P = New PPVG (); p.fliton ();} public int fliton () {Try {fileInputstream DIN = New fileInputs Tream ("ppvg.java"); DIN.READ ();} catch (ioException ie) {system.out.println ("flytwick"); returnome);} finally {system.out.println ("fliton); } return -1;}} Assuming the file Ppvg.java is available to be read which of the following statements are true if you try to compile and run the program 1) The program will run and output only "flytwick" 2) The? Program Will Run and Output Only "Fliton" 3) The Program Will Run and Output Both "fliton" and "flytwick"

4) An error will occur at compile time because the method fliton attempts to return two valuesQ2.What will happen when you attempt to compile and run the following codeimport java.io *;. Class Base {public void amethod () throws FileNotFoundException {} } public class ExcepDemo extends Base {public static void main (String argv []) {ExcepDemo e = new ExcepDemo ();} public void amethod () {} protected ExcepDemo () {try {DataInputStream din = new DataInputStream (System.in ); System.out.println ("pausing"); din.readbyte (); system.out.println ("continuing"); this.amethod ();} catch (ooException ie) {}}} 1) Compile Time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hitQ3.You want to find out the Value of the last element Of an array. what will.?public class myar {public static void main (string argv []) {int [] i = new int = new int [5]; system.out .println (i [5]);}} 1) An error at compile time2) An Error At Run Time3) The value 0 Will Be Output4) The String "Null" Will Be Outputq4.given The Following Code Import Java.IO. *; public class th {public static void main (string argv []) {th t = new TH (); t.amethod ();} public void amethod () {Try {ioCall ();

} Catch (IOException ioe) {}}} What code would be most likely for the body of the ioCall method 1) public void ioCall () throws IOException {DataInputStream din = new DataInputStream (System.in); din.readChar (); } 2) public void ioCall () throw IOException {DataInputStream din = new DataInputStream (System.in); din.readChar ();} 3) public void ioCall () {DataInputStream din = new DataInputStream (System.in); din. readChar ();} 4) public void ioCall throws IOException () {DataInputStream din = new DataInputStream (System.in); din.readChar ();} Q5.What will be output if you try to compile and run the following code, But there is no file caled hello.txt in the current directory ?. Import java.io. *; public class mine {public static void main (string argv []) {mine m = new mine (); system.out.println (M. AMETHOD ());} public int athod () {Try {fileinputstream dis = new fileinputstream ("hello.txt");} catch (filenotfoundexception fne) {system.o Ut.println ("No Such Found"); Return -1;} catch (ioException ooe) {} finally {system.out.println ("doing finally");} return 0;}} 1) No Such File Found 2 No Such File Found, -1 3) No Such File Found, Doing Finally, -1 4) 0 Q1.given The Following Code Import Java.io. *; Public Class Ppvg {Public Static Void Main (String Argv []) {PPVG P = New PPVG (); p.fliton ();} public int fliton (); {fileinputstream din = new fileinputstream ("ppvg.java"); DINREAD ();} catch ({ion ();} System.out.println ("flytwick");

return 99;} finally {System.out.println ( "fliton");} return -1;}} Assuming the file Ppvg.java is available to be read which of the following statements are true if you try to compile and run the program? 1) The program will run and output only "flytwick" 2) The program will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because the method fliton attempts to return two valuesQ2.What will happen when you attempt to compile and run the following codeimport java.io *;. class Base {public void amethod () throws FileNotFoundException {}} public class ExcepDemo extends Base {public static void main (String argv []) {ExcepDemo e = new ExcepDemo ();} public void amethod () {} protected ExcepDemo () {try {DataInputStream din = new DataInputStream (System.in); System.out.println ( "Pausing"); DIN.Readbyte (); System.out.println ( "Continuing"); this.amethod ();} catch (IOException ioe) {}}} 1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hitQ3.You want to find out the value of the last element of an array. You write the following code. What will happen when You Compile and run it.?public class myar {public static void main (string argv []) {int [] i = new int [5]; system.out.println (i [5]);

}} 1) An error at compile time2) An error at run time3) The value 0 will be output4) The string "null" will be outputQ4.Given the following code import java.io *;. Public class Th {public static void Main (String Argv []) {th T = New TH (); T. AMETHOD ();} public void amethod () {ioException ooe {}}} What code Would Be MOST likely for the body of the ioCall method 1) public void ioCall () throws IOException {DataInputStream din = new DataInputStream (System.in); din.readChar ();} 2) public void ioCall () throw IOException {DataInputStream din = new DataInputStream (System.in); din.readChar ();} 3) public void ioCall () {DataInputStream din = new DataInputStream (System.in); din.readChar ();} 4) public void ioCall throws IOException () { DatabasePutStream DIN = New DataInputStream (System.IN); DIN.Readchar ();} Q5.What Will Be Output if you try to compile and rain the following code, but there is no file caled hello.txt in the CUR Rent Directory ?. Import java.io. *; public class mine {public static void main (string argv []) {mine m = new mine (); system.out.println (m.amethod ());} public int amethod () {try {FileInputStream dis = new FileInputStream ( "Hello.txt");} catch (FileNotFoundException fne) {System.out.println ( "No such file found"); return -1;} catch (IOException ioe) {} Finally {system.out.println ("doing firmly");} return 0;

}} 1) No Such Found, -1 3) No Such Found, Doing Finally, -1 4) 0 MODULE 8 - Building Guismodule 9 - The AWT Event ModelModule 10 - The AWT Component LibraryModule 11 - Java Foundation ClassesQ1.You are creating an application that has a form with a text entry field used to enter a persons age. Which of the following is appropriate for capturing this information.1) Use the text field of a TextField and parse the result using Integer2) use the getInteger method of the textField3) use the getText method of a TextBox and parse the result using the getInt method of Integer class4) use the getText method of a TextField and use the parseInt method of the Integer classQ2.Which of the following statements are true? 1) The default layout manager for an Applet is FlowLayout2) The default layout manager for a Frame is FlowLayout3) A layout manager must be assigned to an Applet before the setSize method is called4) The FlowLayout manager attempts to honor the preferred size of any componentsQ3.Which of the following are true? 1) A component may have only one event listener attached at a time2) An event listener may be removed from a component3) The ActionListener interface has no corresponding Adapter class4) The processing of an event listener requires a try / catch block Q4.What will happen when you attempt to compile and run this code // Demonstration of event handlingimport java.awt *;. import java.awt.event *;. public class MyWc extends Frame implements WindowListener {public static void main (string argv []) {mywc mwc = new mywc ();} public void window {system.exit (0);

} // End of windowClosing public void MyWc () {setSize (300,300); setVisible (true);}} // End of class1) Error at compile time2) Visible Frame created that that can be closed3) Compilation but no output at run ? time4) Error at compile time because of comment before import statementsQ5.What most closely matches the appearance when this code runs import java.awt *;. public class CompLay extends Frame {public static void main (String argv []) {CompLay cl = new company ();} complay () {Panel P = new panel (); p.setBackground; P.Add (New Button); P.Add ("Two" ")); P.Add (" Three ")); Add (" South ", P); setLayout (new flowLayout ()); setsize (300, 300); setvisible (true);}} 1) the button will run from left to right along the bottom of the Frame2) The buttons will run from left to right along the top of the frame3) The buttons will not be displayed4) Only button three will show occupying all of the frameQ6.How do you change the current layout manager for a container1) Use the setLayout method2) Once created you can not change the current layout manager of a component3) Use the setLayoutManager method4) Use the updateLayout methodQ7.How do you indicate where a component will be positioned using Flowlayout? 1) North, South, East, West2) Assign a row / column grid reference3) Pass a X / Y percentage parameter to the add method4) Do nothing, the FlowLayout will position the componentQ8.Given the following code import java.awt. * Public class setf extends frame {public static void main (string argv []) {setf s = new setf (); s.setsize (300, 200); s.setVisible (TRUE);

}}}} How Could You Set The Frame Surface Color To Pink 1) S.SetBackground (Color.pink); 2) S.SetColor (PINK); 3) S.back (PINK); 4) S.Color = color.pink Q9.What will be displayed when you attempt to compile and run the following code // code startimport java.awt *;. public class Butt extends Frame {public static void main (String argv []) {Butt MyBut = new Butt () Butt () {Button Hellobut = New Button ("Hello"); Button Byebut = New Button ("BYE"); add (Hellobut); add (300, 300); setvisible;}} // Code end1) Two buttons side by side occupying all of the frame, Hello on the left and Bye on the right 2) One button occupying the entire frame saying Hello 3) One button occupying the entire frame saying Bye 4) Two buttons at Top of the frame oneing hello the other saying by q10.an applet Has iting by ingout manager set to the default of flowlayout. what code would be Correct to Change to another layout manager. 1) setlay Outmanager (New GridLayout ()); 2) SetLayout (2, 2)); 3) SetGridLayout (2, 2); 4) setBorderLayout ();

Module 1 - Getting StartedQ1.4Q2.23Q3.1Q4.2Q5.4Moudle2Module 1 - Getting StartedQ1.4Q2.23Q3.1Q4.2Q5.4Moudle2Module 1 - Getting StartedQ1.4Q2.23Q3.1Q4.2Q5.4Moudle2Q1.124Q2.2Q3.34Q4. 4Q5.4Q6.14Q7.5Q8.1Q9.1345Q10.2345 Module 3 - Expressions and flow controlq1.3q2.2q3.23q4.123Q5.3Q6.1Q7.4Q8.1Q9.4Q10.24Q14.2Q15.3Q16 .2Q17.23Q18.1Q19.3Q20.3Module 4 -. ArraysQ1.4Q2.3Q3.4Q4.2Q5.2Module51.42.43.14.35.2346.27.348.29.410.211.412.413.114.315.2316.117.418.1419.420.123Module61 22. 13. 1234 135. 1236. 1247. 138. 19.210. 1Module71. 22. 43. 24. 15. 3Module8910111. 42. 143. 234. 15. 26. 17. 48. 19. 310. 2Module 2 Identifiers, Keywords, and And Types

Q1.Which of The Following Are Legal Statements?

1) float f = 1/3; 2) INT i = 1/3; 3) float f = 1.01; 4) Double D = 999d;

Q2.Which of The Following Are Java Keywords?

1) NULL2) New3) Instanceof4) Wend

Q3.Which of The Following Are Java Keywords?

1) SIZEOF2) Main3) Transient4) Volatile

Q4.given the folowing declaration

Integer i = new integer (99);

How can you now set the value of i to 10?

1) i = 10; 2) I.SetValue (10); 3) I.PARSEINT (10); 4) None of the Above

Q5.Which of the Following Will Compile Correctly

1) Short myshort = 99s; 2) String name = 'Excellent Tutorial Mr Green'; 3) CHAR C = 17c; 4) INT Z = 015;

Q6.Which of The Following Are Java Key Words1) Double2) Switch3) THEN4) InstanceOf

Q7.Which of the folowing lines will compile without warning or error.

1) float f = 1.3; 2) CHAR C = "a"; 3) BYTE B = 257; 4) Boolean B = NULL; 5) INT I = 10;

Q8.A Byte Can Be of What size

1) -128 TO 127 2) (-2 Power 8) -1 to 2 Power 8 3) -255 to 256 4) Depends on the particular impLementation of the Java Virtual Machineq9.Which of the Following Area Keywords Or Reserved Words in Java ?

1) IF 2) THEN 3) GOTO 4) WHILE 5) CASE

Q10.Which of the folloading area Legal IdentifierS

1) 2Variable 2) Variable2 3) _Whatavariable 4) _3_5) $ anothervar 6) #myvar

Module 4 - Arrays

Q1.WHAT code placed after the comment // for loop Would Result in the population of every of the array ia [] with a value from variable i.?

Public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You want to find out the value of the last element of an array. You Write the Following Code. What Will Happen When You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5]; system.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q5.Which of The Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method

Module 4 - Arrays

Q1.WHAT code placed after the comment // for loop Would Result in the population of every of the array ia [] with a value from variable i.?

Public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You Wei To Find Out The Value of The Last Element of an Array. You Write The Following Code. What Will Happen When You Compile and Run It.?public Class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q5.Which of The Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method

Module 4 - Arrays

Q1.WHAT code placed after the comment // for loop Would Result in the population of every of the array ia [] with a value from variable i.?

Public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv []) {

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You want to find out the value of the last element of an array. You Write the Following Code. What Will Happen When You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q5.Which of The Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method

Module 3 - Expressions and Flow Control

Q1.WHAT WILL BE PRINTED OUT IF You Attempt To Compile and Run THE FOLLOWING CODE?

INT i = 1;

Switch (i) {

Case 0:

System.out.println ("Zero");

Break;

Case 1:

System.out.println ("One");

Case 2:

System.out.println ("Two");

DEFAULT:

System.out.println ("Default");

}

1) One 2) One, Default 3) One, Two, Default 4) DEFAULT

Q2.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");

}

1) DEFAULT 2) Default, Zero 3) Error Default Clause Not Defeed 4) No Output Displayed

Q3.Which of The Following Lines of Code Will Compile With Error1)

INT i = 0;

IF (i) {

System.out.Println ("Hello");

}

2)

Boolean b = true;

Boolean B2 = True;

IF (b == b2) {

System.out.println ("so true");

}

3)

INT i = 1;

INT J = 2;

IF (i == 1 || j == 2)

System.out.println ("OK");

4)

INT i = 1;

INT J = 2;

IF (i == 1 & | j == 2)

System.out.println ("OK");

Q4.Which of the following statements are TRUE?

1) System.out.println (-1 >>> 2); Will Output A Result Larger Than 102) System.out.Println (-1 >>> 2); Will Output A Positive Number 3) System.out.println (2 >> 1); Will Output The Number 1 4) System.out.println (1 <<< 2); Will Output The Number 4

Q5.WHAT WILL HAPPEN IF you attempt to compile and weight? FOLLOWING CODE?

Integer ten = new integer (10);

Long nine = new long (9);

System.out.println (Ten Nine);

INT i = 1;

System.out.println (i ten);

1) 19 Followed by 20 2) 19 Followed by 11 3) Compile Time Error 4) 10 FOLLOWED BY 1

Given the folowing declarations

String S1 = New String ("Hello")

String s2 = new string ("there");

String s3 = new string ();

Q6.Which of The Following Are Legal Operations?

1) S3 = S1 S2; 2) S3 = S1-S2; 3) S3 = S1 & S2; 4) S3 = S1 && S2

Q7.What is the result of the folowing operation?

System.out.println (4 | 3);

1) 6 2) 0 3) 1 4) 7

Q8.What will happen when you attempt to compile and rain the following code

Public class myswitch {

Public static void main (String Argv []) {

MySwitch MS = new myswitch ();

Ms.amethod ();

}

Public void amethod () {

INT K = 10;

Switch (k) {

DEFAULT: / / PUT The Default At the Bottom, Not HereSystem.out.println ("this is the default output");

Break;

Case 10:

System.out.println ("Ten");

Case 20:

System.out.println ("twenty");

Break;

}

}

}

1) None of these options2) Compile and Run with output "this is the default output" 4) compile and run "4) Compile and run" ten "

Q9.What Will Happen when you attempt to compile and rain the following code

INT OUTPUT = 10;

Boolean B1 = FALSE;

IF ((b1 == true) && ((Output = 10) == 20)) {

System.out.println ("We Are Equal" Output;

Else

{

System.out.println ("NOT Equal!" Output;

}

1) Compile Error, Attempting to Peform Binary Compilation and ON Logical Data Type2) Compilation and Output of "We Are Equal 10" 3) Compilation and Output of "NOT Equal! 20" 4) Compilation and Output of "Not Equal! 10"

Q10.GIVEN THE FOLLOWING VARIABLES Which of the FOLLOWING LINES WILL COMPILE WITHOUT ERROR?

String s = "hello";

Long L = 99;

Double D = 1.11;

INT i = 1;

INT j = 0;

1) j = i << s;

2) j = i << j;

3) j = i << d;

4) j = i << l;

Q11.What Will Be Output by The Following Line of Code?

System.out.println (010 | 4);

1) 142) 03) 64) 12

Given the Following Variables

CHAR C = 'c';

INT i = 10;

Double D = 10;

Long L = 1;

String s = "hello";

Q12.Which of the Following Will Compile WITHOUT ERROR?

1) C = C I; 2) S = I; 3) i = S; 4) C = S;

Q13.Which of The Following Will Compile WITHOUT ERROR?

1)

CHAR C = '1'; system.out.println (C >> 1); 2)

Integer i = integer ("1"); system.out.println (i >> 1);

3)

INT i = 1; system.out.println (i <<< 1);

4)

INT i = 1; System.out.Println (i << 1);

Q14.Which of The Following Statements Are True?

1) The String class is implemented as a char array, elements are addressed using the stringname [] convention2) The operator is overloaded for concatenation for the String class3) Strings are a primitive type in Java and the StringBuffer is used as the matching wrapper TYPE4) The size of a string can be retrieved Using The Length Property

Q15.Which of The Following Statements Are True?

1) The following statement will produce a result of 1. System.out.println (-1 >>> 2); 2) Performing an unsigned left shift (<<<) on a negative number will always produce a negative number result3) The Following Statement Will Produce A Result of Zero, System.out.Println (1 >> 1); 4) All The Java Integral Types Are Signed Numbers

Q16. Given The Following Class

Public class omb isolaley {

Public static void main (String Argv []) {

Boolean B1 = True;

IF ((B1 == True) || Place (TRUE)) {

System.out.println ("Hello Crowle");

}

}

Public Static Boolean Place (Boolean Location) {

IF (location == true) {

System.out.println ("borcetshire");

}

System.out.println ("Powick");

Return True;

}

}

What WILL HAPPEN WHEN You Attempt To Compile and Run IT?

1) Compile Time error2) Output of "Hello Crowle" 3) Output of borcetshire and power "Hello Crowle" 4) No Output

Q17. Which of the folloading statements are TRUE?

1) THE% IS Used to Calculate a Percentage Thus: 10% 20 = 502) The / Operator IS Used to Divide One Value By Another3) The # symbol May Not Be Used As The First Character of a Variable4) The $ SYMBOL MAY NOT BE USED As the first character of a variableq18.what Will Happen WHEN You Attempt to compile and run the following code?

PUBLIC Class Agg {

Static public long i = 10;

Public static void main (String Argv []) {

Switch (i) {

DEFAULT:

System.out.println ("No Value Given");

Case 1:

System.out.println ("One");

Case 10:

System.out.println ("Ten");

Case 5:

System.out.println ("FIVE");

}

}

}

1) Compile Time Error2) Output of "Ten" FOLLOWED BY "3) Output of" Ten "4) Compilation and Run Time Error Because of Location of DEFAULT

Q19.What Will Happen when you attempt to compile and rain the following code

Public class streq {

Public static void main (String Argv []) {

Streq s = new streq ();

}

Private streq () {

String s = "marcus";

String S2 = New String ("marcus");

IF (s == s2) {

System.out.println ("We Have A Match");

} else {

System.out.println ("Not Equal");

}

}

}

1) Compile Time Error Caused by Private Constructor2) Output of "We Have A Match" 3) Output of "Not Equal" 4) Compile Time Error By Attempting to Compare Strings Using ==

Q20.given the following code, what test would you need to put in place of the comment line?

// Place Test Here

To Result in An Output of the string equal

Public class eqtest {

Public static void main (String Argv []) {

EQTEST E = New EQTEST ();

}

EQTEST () {

String s = "java";

String S2 = "java";

// Place test here {

System.out.println ("Equal");} else

{

System.out.println ("Not Equal");

}

}

}

1) IF (S == S2) 2) IF (S.EqualsignoreCase (S2)) 4) IF (S.NocaseMatch (S2))

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC ();

INT i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter TypeSq5.given the Following Class Definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses For the Same Method Name4) a class is prevented from accessing methods in its immediate anncestor

Q7.Which of the folloading statements are TRUE?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {

Public static void main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and output of the string "Severn" at runtime2) Compile time error3) Compilation and no output at runtime4) Compilation and output of the string "Base" Q9.Which of the following statements are true?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following code

Class base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile Time Error Base Is A Keyword2) Compilation and No Output At Runtime3) Output of Base4) Runtime Error Base Has No Valid Constructor

Q11.What will happen when you attempt to compile and rain the Following Code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addelement (99);

3) Vector v = new vector (); v.Add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.What Will Happen WHEN You TRY COMPILING AND RUNNING THIS CODE? PUBLIC CLAS REF {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (Ref r) {

R.I = r.i * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.given the following class definition Which of the folloading can be leGally Placed After the comment line //th?

Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public class rid {

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void afancymethod () {

System.out.println ("What a Fancy Method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ()); Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC ();

INT i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses FOR THE SAME MEVEND NAME4) A Class Is Prevented from Accessing Methods in ITS IMMEDIATE ANCESTORQ7.WHICH OF THE FOLLOWING STATEments Are True?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {

Public static void main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following code

Class base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile time error Base is a keyword2) Compilation and no output at runtime3) Output of Base4) Runtime error Base has no valid constructorQ11.What will happen when you attempt to compile and run the following code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addelement (99);

3) Vector v = new vector (); v.Add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (Ref r) {

R.I = r.i * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.given the following class definition Which of the folloading can be leGally Placed After the comment line //th?

Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public class rid {

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void AfancyMethod () {system.out.println ("what a fancy method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC ();

INT i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses For the Same Method Name4) a class is prevented from accessing methods in its immediate anncestor

Q7.Which of the folloading statements are TRUE?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {Public Static Void Main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following code

Class base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile Time Error Base Is A Keyword2) Compilation and No Output At Runtime3) Output of Base4) Runtime Error Base Has No Valid Constructor

Q11.What will happen when you attempt to compile and rain the Following Code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addeElement (99); 3) Vector v = new vector (); v.add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (Ref r) {

R.I = r.i * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.Given the following class definition which of the folloading can be legally placed after the comment line // here? Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public class rid {

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void afancymethod () {

System.out.println ("What a Fancy Method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 6 - Advanced Language FeaturesQ1.What will happen when you attempt to compile and run the following code.public class Pvf {static boolean Paddy; public static void main (String argv []) {System.out.println (Paddy);} } 1) Compile time error2) compilation and output of false3) compilation and output of true4) compilation and output of nullQ2.What will happen when you attempt to compile and run the following codeclass Base {protected int i = 99;} public class Ab {Private INT i = 1; public static void main (string argv []) {ab a = new ab (); a.hallow ();} Abstract void Hallow () {system.out.println ("Claines" i );}} 1) Compile time error2) Compilation and output of Claines 993) Compilation and output of Claines 14) Compilation and not output at runtimeQ3.Given the following codeclass Base {static int oak = 99;} public class Doverdale extends Base { Public static void main (string argv []) {DOVERDALE D = New Doverdale (); D. AMETHOD ();} public void AMETHOD () {// Here}} Which of the fol, means, will compile and model, will compile and modify the value of the variable oak? 1) Super.oak = 1; 2) Oak = 33; 3) Base .OAK = 22; 4) OAK = 50.1;

Q4.Which of the following statements are true? 1) A method in an interface must not have a body2) A class may extend one other class plus at most one interface3) A class may extends at most one other class plus implement many interfaces4) via class accesses an interface An the keyword usesQ5.Which of the following statements are true? 1) static methods do not have access to the implicit variable called this2) A static method may be called without creating an instance of its class3) A static method may not be overriden to be non-static4) A static method may not be overloadedQ6.Given the folowing classes which of the following will compile without error? interface iFace {} class CFace implements iFace {} class Base {} public class ObRef extends Base {Public static void main (string argv []) {obref ob = New obref (); base b = new base (); object o1 = new object (); ifce o2 = new cface ();}} 1) O1 = O2; 2) b = ob; 3) OB = B; 4) O1 = B; Q7.Given the Following Code

Class Base {}

Public class mycast extends base {

Static Boolean B1 = FALSE;

Static Int i = -1;

Static Double D = 10.1;

Public static void main (String Argv []) {

Mycast m = new mycast ();

Base b = new base ();

// hERE

}

}

Which of the following, if infrest at the copy to compile and run withoutow the code = m; 2) m = b; 3) D = i; 4) b1 = i;

Q8.What will happen when you attempt to compile and rain the folowing code with the command line "Hello there"

Public class arg {

String [] myarg;

Public static void main (String Argv []) {

Myarg = argv;

}

Public void amethod () {

System.out.println (Argv [1]);

}

}

1) Compilation Time Error2) Compilation and Output of "Hello" 3) Compilation and Output of "There" 4) NONE OF THE ABOVEQ9.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run this code?

Class base {

Abstract public void myfunc ();

Public void another () {

System.out.println ("ANOTHER METHOD");

}

}

Public class abs Extends base {

Public static void main (String Argv []) {

ABS A = New ABS ();

a.amethod ();

}

Public void myfunc () {

System.out.println ("My FUNC");

}

Public void amethod () {

Myfunc ();

}

}

1) The code will compile and run, printing out the words "My Func" 2) The compiler will complain that the Base class is not declared as abstract.3) The code will compile but complain at run time that the Base class has non Abstract methods4) The Compiler Will Complain That The Method Myfunc in The Base Class Has No Body, Nobody At All to Look IT

Q10.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run this code?

Abstract class base {

Abstract public void myfunc ();

Public void another () {

System.out.println ("ANOTHER METHOD");

}

}

Public class abs Extends base {

Public static void main (String Argv []) {

ABS A = New ABS ();

a.amethod ();

}

Public void myfunc () {

System.out.println ("My FUNC");

}

Public void amethod () {

Myfunc ();

}

}

1) The code will compile and run, printing out the words "My Func" 2) The compiler will complain that the Base class has non abstract methods3) The code will compile but complain at run time that the Base class has non abstract methods4) The Compiler Will Complain That The Method Myfunc in The Base Class Has No Body, Nobody At All to Look IT

Q1.given the folowing code

Import java.io. *;

PUBLIC CLASS PPVG {

Public static void main (string argv []) {ppvg p = new PPVG ();

p.fliton ();

}

Public int fliton () {

Try {

FileInputStream DIN = New FileInputStream ("ppvg.java");

DIN.READ ();

} catch (ioexception ie) {

System.out.println ("flytwick");

Return 99;

} finally {

System.out.println ("Fliton");

}

Return -1;

}

}

Assuming the file ppvg.java Is Available To Be Read Which of The Following Statements Are True if you try??

1) The program will run and output only "flytwick" 2) The program will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because The Method fliton attempts to return Two Values

Q2.What will happen when you attempt to compile and rain the Following Code

Import java.io. *;

Class base {

Public void amethod () throws filenotfoundexception {}

}

Public class excepdemo extends base {

Public static void main (String Argv []) {

ExcepDemo E = New ExcepDemo ();

}

Public void amethod () {}

protected excepdemo () {

Try {

DataInputStream DIN = New DataInputStream (System.in);

System.out.println ("PAUSING");

DIN.READBYTE ();

System.out.println ("Continuing");

THIS.AMETHOD ();

} catch (ioexception ie) {}

}

}

1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hit

Q3.You Wei To Find Out The Value of The Last Element of an Array. You WRITE The FOLLOWING CODE. What WILL HAPPEN WHEN You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q4.given The Following Code

Import java.io. *;

Public Class TH {

Public static void main (String Argv []) {

TH t = new TH ();

T.amethod ();

}

Public void amethod () {

Try {

Iocall ();

} catch (ioexception ie) {}

}

}

What Code Would Be Most Likey for the Body of The Iocall Method

1) Public void ocall () throws oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

2) public void ocall () throw oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

3) Public void ocall () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

4) Public void ocall throws oews oException () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

Q5.WHAT WILL Be Output if you try to compile and rain the following code, but there is no file called hello.txt in the current directory?

Import java.io. *;

Public class mine {

Public static void main (String Argv []) {

Mine m = new mine ();

System.out.println (M.AMethod ());

}

Public int athod () {

Try {

FileInputStream DIS = New FileInputStream ("Hello.txt");

} catch (filenotfoundexception fne) {

System.out.println ("No Such File");

Return -1;

} catch (ioexception ie) {

} finally {

System.out.println ("Doing Finally");

}

Return 0;

}

}

1) No Such File Found 2 No Such Found, -1 3) No Such File Found, Doing Finally, -1 4) 0

Q1.given the folowing code

Import java.io. *;

PUBLIC CLASS PPVG {

Public static void main (string argv []) {ppvg p = new PPVG ();

p.fliton ();

}

Public int fliton () {

Try {

FileInputStream DIN = New FileInputStream ("ppvg.java");

DIN.READ ();

} catch (ioexception ie) {

System.out.println ("flytwick");

Return 99;

} finally {

System.out.println ("Fliton");

}

Return -1;

}

}

Assuming the file ppvg.java Is Available To Be Read Which of The Following Statements Are True if you try??

1) The program will run and output only "flytwick" 2) The program will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because The Method fliton attempts to return Two Values

Q2.What will happen when you attempt to compile and rain the Following Code

Import java.io. *;

Class base {

Public void amethod () throws filenotfoundexception {}

}

Public class excepdemo extends base {

Public static void main (String Argv []) {

ExcepDemo E = New ExcepDemo ();

}

Public void amethod () {}

protected excepdemo () {

Try {

DataInputStream DIN = New DataInputStream (System.in);

System.out.println ("PAUSING");

DIN.READBYTE ();

System.out.println ("Continuing");

THIS.AMETHOD ();

} catch (ioexception ie) {}

}

}

1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hit

Q3.You Wei To Find Out The Value of The Last Element of an Array. You WRITE The FOLLOWING CODE. What WILL HAPPEN WHEN You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q4.given The Following Code

Import java.io. *;

Public Class TH {

Public static void main (String Argv []) {

TH t = new TH ();

T.amethod ();

}

Public void amethod () {

Try {

Iocall ();

} catch (ioexception ie) {}

}

}

What Code Would Be Most Likey for the Body of The Iocall Method

1) Public void ocall () throws oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

2) public void ocall () throw oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

3) Public void ocall () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

4) Public void ocall throws oews oException () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

Q5.WHAT WILL Be Output if you try to compile and rain the following code, but there is no file called hello.txt in the current directory?

Import java.io. *;

Public class mine {

Public static void main (String Argv []) {

Mine m = new mine ();

System.out.println (M.AMethod ());

}

Public int athod () {

Try {

FileInputStream DIS = New FileInputStream ("Hello.txt");

} catch (filenotfoundexception fne) {

System.out.println ("No Such File");

Return -1;

} catch (ioexception ie) {

} finally {

System.out.println ("Doing Finally");

}

Return 0;

}

}

1) No Such File Found 2 No Such Found, -1 3) No Such File Found, Doing Finally, -1 4) 0

Q1.given the folowing code

Import java.io. *;

PUBLIC CLASS PPVG {

Public static void main (string argv []) {ppvg p = new PPVG ();

p.fliton ();

}

Public int fliton () {

Try {

FileInputStream DIN = New FileInputStream ("ppvg.java");

DIN.READ ();

} catch (ioexception ie) {

System.out.println ("flytwick");

Return 99;

} finally {

System.out.println ("Fliton");

}

Return -1;

}

}

Assuming the file ppvg.java Is Available To Be Read Which of The Following Statements Are True if you try??

1) The program will run and output only "flytwick" 2) The program will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because The Method fliton attempts to return Two Values

Q2.What will happen when you attempt to compile and rain the Following Code

Import java.io. *;

Class base {

Public void amethod () throws filenotfoundexception {}

}

Public class excepdemo extends base {

Public static void main (String Argv []) {

ExcepDemo E = New ExcepDemo ();

}

Public void amethod () {}

protected excepdemo () {

Try {

DataInputStream DIN = New DataInputStream (System.in);

System.out.println ("PAUSING");

DIN.READBYTE ();

System.out.println ("Continuing");

THIS.AMETHOD ();

} catch (ioexception ie) {}

}

}

1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hit

Q3.You Wei To Find Out The Value of The Last Element of an Array. You WRITE The FOLLOWING CODE. What WILL HAPPEN WHEN You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q4.given The Following Code

Import java.io. *;

Public Class TH {

Public static void main (String Argv []) {

TH t = new TH ();

T.amethod ();

}

Public void amethod () {

Try {

Iocall ();

} catch (ioexception ie) {}

}

}

What Code Would Be Most Likey for the Body of The Iocall Method

1) Public void ocall () throws oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

2) public void ocall () throw oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

3) Public void ocall () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

4) Public void ocall throws oews oException () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

Q5.WHAT WILL Be Output if you try to compile and rain the following code, but there is no file called hello.txt in the current directory?

Import java.io. *;

Public class mine {

Public static void main (String Argv []) {

Mine m = new mine ();

System.out.println (M.AMethod ());

}

Public int athod () {

Try {

FileInputStream DIS = New FileInputStream ("Hello.txt");

} catch (filenotfoundexception fne) {

System.out.println ("No Such File");

Return -1;

} catch (ioexception ie) {

} finally {

System.out.println ("Doing Finally");

}

Return 0;

}

}

1) No Such File Found 2 No Such Found, -1 3) No Such File Found, Doing Finally, -1 4) 0

Module 8 - Building Guis

Module 9 - The AWT Event Model

Module 10 - The AWT Component LibraryModule 11 - Java Foundation Classes

Q1.You area Creating An Application That Has A Form With a Text Entry Field Used to Enter a Persons Age. Which of the Following IS Appropriate for Capturing this Information.

1) Use the Text field of a TextField and parse the result using Integer2) Use the getInteger method of the TextField3) Use the getText method of a TextBox and parse the result using the getInt method of Integer class4) Use the getText method of a TextField And use the parseint method of the integer class

Q2.Which of The Following Statements Are True?

1) The default layout manager for an Applet is FlowLayout2) The default layout manager for a Frame is FlowLayout3) A layout manager must be assigned to an Applet before the setSize method is called4) The FlowLayout manager attempts to honor the preferred size of any components

Q3.Which of the following area?

1) A component may have only one event listener attached at a time2) An event listener may be removed from a component3) The ActionListener interface has no corresponding Adapter class4) The processing of an event listener requires a try / catch block

Q4.What will happen when you attempt to compile and rain this code

// Demonstration of Event HANDLING

Import java.awt. *;

Import java.awt.event. *;

Public class mywc extends frame imports windowlistener {

Public static void main (String Argv []) {

MYWC MWC = New MYWC ();

}

Public void windowclosing (windowevent wE) {

System.exit (0);

} // end of windowClosing

Public void mywc () {

Setsize (300, 300);

SetVisible (TRUE);

}

} // End of class

1) Error at compile time2) Visible Frame created that that can be closed3) Compilation but no output at run time4) Error at compile time because of comment before import statementsQ5.What most closely matches the appearance when this code runs?

Import java.awt. *;

Public class company extends frame {

Public static void main (String Argv []) {

CompLay Cl = New Complay ();

}

Complay () {

PANEL P = new panel ();

P.SetBackground (Color.pink);

P.ADD (New Button ("one"));

P.ADD (New Button));

P.ADD (New Button ("Three"));

Add ("South", P);

SetLayout (New FlowLayout ());

Setsize (300, 300);

SetVisible (TRUE);

}

}

1) The buttons will run from left to right along the bottom of the Frame2) The buttons will run from left to right along the top of the frame3) The buttons will not be displayed4) Only button three will show occupying all of the frame

Q6.how do you change The Current Layout Manager for a Container

1) Use the setLayout Method2) ONCE CREATED You Cannot Change The Current Layout Manager of a Component3) Use The setTlayoutManager Method4) Use the UpdateLayout Method

Q7.how do you indeicate where a company?

1) North, South, East, West2) Assign a Row / Column Grid Reference3) Pass A X / Y Percentage Parameter To The Add Method4) Do Notning, The FlowLayout Will Position The Component

Q8.given The Following Code

Import java.awt. *;

Public class setf extends frame {

Public static void main (String Argv []) {

Setf s = new setf ();

S.setsize (300, 200);

S.SetVisible (TRUE);

}

}

How Could You Set The Frame Surface Color To Pink

1) s.SetBackground; 2) s.SetColor (PINK); 3) S.background (PINK); 4) S.COLOR = Color.pink

Q9.WHAT WILL BE Displayed When You Attempt To Compile and Run The Following Code // Code Start

Import java.awt. *;

Public class butt extends frame {

Public static void main (String Argv []) {

Butt mybut = new butt ();

}

Butt () {

Button hellobut = New Button ("Hello");

Button Byebut = New Button ("BYE");

Add (Hellobut);

Add (Byebut);

Setsize (300, 300);

SetVisible (TRUE);

}

}

// code end

1) Two buttons side by side occupying all of the frame, Hello on the left and Bye on the right 2) One button occupying the entire frame saying Hello 3) One button occupying the entire frame saying Bye 4) Two buttons at the top of The frame one saying hello the Other Saying Bye

Q10.An Applet Has Its Layout Manager set to the default of flowLayout. What code would be Correct to change to another layout manager.

1) setLayoutManager (New GridLayout ()); 2) SetLayout (2, 2)); 3) SetGridLayout (2, 2); 4) SetBorderLayout ();

Module 1 - Getting Started

Q1.4

Q2.23

Q3.1

Q4.2

Q5.4

Moudle2

Module 1 - Getting Started

Q1.4

Q2.23

Q3.1

Q4.2

Q5.4

Moudle2

Module 1 - Getting Started

Q1.4

Q2.23

Q3.1

Q4.2

Q5.4

Moudle2

Q1.124

Q2.2

Q3.34

Q4.4

Q5.4

Q6.14

Q7.5

Q8.1

Q9.1345

Q10.2345

Module 3 - Expressions and Flow Control

Q1.3

Q2.2

Q3.23

Q4.123

Q5.3

Q6.1

Q7.4

Q8.1

Q9.4

Q10.24

Q11.4

Q12.2

Q13.14

Q14.2

Q15.3

Q16.2

Q17.23

Q18.1

Q19.3

Q20.3

Module 4 - Arrays

Q1.4

Q2.3

Q3.4

Q4.2

Q5.2

Module5

1.4

2.4

3.1

4.3

5.234

6.2

7.34

8.2

9.4

10.2

11.4

12.4

13.1

14.3

15.23

16.1

17.4

18.14

19.4

20.123

Module6

1. 22. 13. 1234. 135. 1236. 1247. 138. 19. 210. 1Module71. 22. 43. 24. 15. 3Module8910111. 42. 143. 234. 15. 26. 17.48. 19. 310. 2Module 2 Identifiers, Keywords, and Types

Q1.Which of The Following Are Legal Statements?

1) float f = 1/3; 2) INT i = 1/3; 3) float f = 1.01; 4) Double D = 999d;

Q2.Which of The Following Are Java Keywords?

1) NULL2) New3) Instanceof4) Wend

Q3.Which of The Following Are Java Keywords?

1) SIZEOF2) Main3) Transient4) Volatile

Q4.given the folowing declaration

Integer i = new integer (99);

How can you now set the value of i to 10?

1) i = 10; 2) I.SetValue (10); 3) I.PARSEINT (10); 4) None of the Above

Q5.Which of the Following Will Compile Correctly

1) Short myshort = 99s; 2) String name = 'Excellent Tutorial Mr Green'; 3) CHAR C = 17c; 4) INT Z = 015;

Q6.Which of The Following Are Java Key Words1) Double2) Switch3) THEN4) InstanceOf

Q7.Which of the folowing lines will compile without warning or error.

1) float f = 1.3; 2) CHAR C = "a"; 3) BYTE B = 257; 4) Boolean B = NULL; 5) INT I = 10;

Q8.A Byte Can Be of What size

1) -128 to 127 2) (-2 Power 8) -1 to 2 Power 8 3) -255 TO 256 4) Depends on the particular implementation of the java virtual machineine

Q9.Which of The Following Area Keywords Or Reserved Words in java?

1) IF 2) THEN 3) GOTO 4) WHILE 5) CASE

Q10.Which of the folloading area Legal IdentifierS

1) 2Variable 2) Variable2 3) _Whatavariable 4) _3_5) $ anothervar 6) #myvar

Module 4 - Arrays

Q1.What code placed after the comment // for loop Would Result in the population of every equipment of the array ia [] with a value from variable i.?public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You want to find out the value of the last element of an array. You Write the Following Code. What Will Happen When You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q5.Which of The Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method 4 - arrays

Q1.WHAT code placed after the comment // for loop Would Result in the population of every of the array ia [] with a value from variable i.?

Public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You want to find out the value of the last element of an array. You Write the Following Code. What Will Happen When You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at compile3) The value 0 Will Be Output4) The string "Null" Will Be Outputq5.Which of the Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method

Module 4 - Arrays

Q1.WHAT code placed after the comment // for loop Would Result in the population of every of the array ia [] with a value from variable i.?

Public class lin {

Public static void main (String Argv []) {

Lin L = new lin ();

L. AMETHOD ();

}

Public void amethod () {

INT IA [] = new int rt [4];

// Start for loop

{

IA [i] = i;

System.out.println (IA [i]);

}

}

}

1) for (int i = 0; I

Q2.WHAT WILL HAPPEN IF YOU TRY TO Compile and Run The Following Code?

PUBLIC CLASS {

Public static void main (String Argv []) {

INT Anar [] = new int rt [5];

System.out.println (Anar [0]);

}

}

1) Error: Anar is reference 2) NULL 3) 0 4) 5

Q3.WHAT WILL BE Printed Out IF this code is run?

Java myprog good morning

Public class myprog {

Public static void main (String Argv [])

{

System.out.println (Argv [2])

}

}

1) MYPROG 2) GOOD 3) MORNING 4) Exception raised: "java.lang.ArrayindexOutofboundsexception: 2"

Q4.You Wei To Find Out The Value of The Last Element of an Array. You Write The Following Code. What Will Happen When You Compile and Run It.?public Class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q5.Which of The Following Statements Are True?

1) The elements in a Java array can only be of primitive types, not objects2) Arrays elements are initialized to default values ​​wherever they are created using the keword new3) An array may be dynamically resized using the setSize method4) You can find out the Size of an array using the size method

Module 3 - Expressions and Flow Control

Q1.WHAT WILL BE PRINTED OUT IF You Attempt To Compile and Run THE FOLLOWING CODE?

INT i = 1;

Switch (i) {

Case 0:

System.out.println ("Zero");

Break;

Case 1:

System.out.println ("One");

Case 2:

System.out.println ("Two");

DEFAULT:

System.out.println ("Default");

}

1) One 2) One, Default 3) One, Two, Default 4) DEFAULT

Q2.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");

}

1) DEFAULT 2) Default, Zero 3) Error Default Clause Not Defeed 4) No Output Displayed

Q3.Which of the Following Lines of code Will Compile With Error

1)

INT i = 0;

IF (i) {

System.out.Println ("Hello");

}

2)

Boolean b = true;

Boolean B2 = True;

IF (b == b2) {

System.out.println ("so true");

3)

INT i = 1;

INT J = 2;

IF (i == 1 || j == 2)

System.out.println ("OK");

4)

INT i = 1;

INT J = 2;

IF (i == 1 & | j == 2)

System.out.println ("OK");

Q4.Which of the following statements are TRUE?

1) System.out.println (-1 >>> 2); Will Output A Result Larger Than 102) System.out.Println (-1 >>> 2); Will Output A Positive Number 3) System.out.println (2 >> 1); Will Output The Number 1 4) System.out.println (1 <<< 2); Will Output The Number 4

Q5.WHAT WILL HAPPEN IF you attempt to compile and weight? FOLLOWING CODE?

Integer ten = new integer (10);

Long nine = new long (9);

System.out.println (Ten Nine);

INT i = 1;

System.out.println (i ten);

1) 19 Followed by 20 2) 19 Followed by 11 3) Compile Time Error 4) 10 FOLLOWED BY 1

Given the folowing declarations

String S1 = New String ("Hello")

String s2 = new string ("there");

String s3 = new string ();

Q6.Which of The Following Are Legal Operations?

1) S3 = S1 S2; 2) S3 = S1-S2; 3) S3 = S1 & S2; 4) S3 = S1 && S2

Q7.What is the result of the folowing operation?

System.out.println (4 | 3);

1) 6 2) 0 3) 1 4) 7

Q8.What will happen when you attempt to compile and rain the following code

Public class myswitch {

Public static void main (String Argv []) {

MySwitch MS = new myswitch ();

Ms.amethod ();

}

Public void amethod () {

INT K = 10;

Switch (k) {

Default: // Put The Default At the Bottom, Not Here

System.out.println ("this is the default output";

Break;

Case 10:

System.out.println ("Ten");

Case 20:

System.out.println ("twenty");

Break;

}

}

}

1) None of these options2) Compile time error target of switch must be an integral type3) Compile and run with output "This is the default output" 4) Compile and run with output of the single line "ten" Q9.What will happen When You Attempt to Compile and Run The Following Code

INT OUTPUT = 10;

Boolean B1 = FALSE;

IF ((b1 == true) && ((Output = 10) == 20)) {

System.out.println ("We Are Equal" Output;

Else

{

System.out.println ("NOT Equal!" Output;

}

1) Compile Error, Attempting to Peform Binary Compilation and ON Logical Data Type2) Compilation and Output of "We Are Equal 10" 3) Compilation and Output of "NOT Equal! 20" 4) Compilation and Output of "Not Equal! 10"

Q10.GIVEN THE FOLLOWING VARIABLES Which of the FOLLOWING LINES WILL COMPILE WITHOUT ERROR?

String s = "hello";

Long L = 99;

Double D = 1.11;

INT i = 1;

INT j = 0;

1) j = i << s;

2) j = i << j;

3) j = i << d;

4) j = i << l;

Q11.What Will Be Output by The Following Line of Code?

System.out.println (010 | 4);

1) 142) 03) 64) 12

Given the Following Variables

CHAR C = 'c';

INT i = 10;

Double D = 10;

Long L = 1;

String s = "hello";

Q12.Which of the Following Will Compile WITHOUT ERROR?

1) C = C I; 2) S = I; 3) i = S; 4) C = S;

Q13.Which of The Following Will Compile WITHOUT ERROR?

1)

CHAR C = '1'; System.out.Println (C >> 1);

2)

Integer i = integer ("1"); system.out.println (i >> 1);

3)

INT i = 1; system.out.println (i <<< 1);

4)

INT i = 1; System.out.Println (i << 1);

Q14.Which of the following statements are true? 1) The String class is implemented as a char array, elements are addressed using the stringname [] convention2) The operator is overloaded for concatenation for the String class3) Strings are a primitive type in Java and the stringbuffer is buy as the matching wrapper type4) The size of a string can be retrieved Using The Length Property

Q15.Which of The Following Statements Are True?

1) The following statement will produce a result of 1. System.out.println (-1 >>> 2); 2) Performing an unsigned left shift (<<<) on a negative number will always produce a negative number result3) The Following Statement Will Produce A Result of Zero, System.out.Println (1 >> 1); 4) All The Java Integral Types Are Signed Numbers

Q16. Given The Following Class

Public class omb isolaley {

Public static void main (String Argv []) {

Boolean B1 = True;

IF ((B1 == True) || Place (TRUE)) {

System.out.println ("Hello Crowle");

}

}

Public Static Boolean Place (Boolean Location) {

IF (location == true) {

System.out.println ("borcetshire");

}

System.out.println ("Powick");

Return True;

}

}

What WILL HAPPEN WHEN You Attempt To Compile and Run IT?

1) Compile Time error2) Output of "Hello Crowle" 3) Output of borcetshire and power "Hello Crowle" 4) No Output

Q17. Which of the folloading statements are TRUE?

1) THE% IS Used to Calculate a Percentage Thus: 10% 20 = 502) The / Operator IS Used to Divide One Value By Another3) The # symbol May Not Be Used As The First Character of a Variable4) The $ SYMBOL MAY NOT Be buy as the first character of a variable

Q18.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run The Following Code? Public Class Agg {

Static public long i = 10;

Public static void main (String Argv []) {

Switch (i) {

DEFAULT:

System.out.println ("No Value Given");

Case 1:

System.out.println ("One");

Case 10:

System.out.println ("Ten");

Case 5:

System.out.println ("FIVE");

}

}

}

1) Compile Time Error2) Output of "Ten" FOLLOWED BY "3) Output of" Ten "4) Compilation and Run Time Error Because of Location of DEFAULT

Q19.What Will Happen when you attempt to compile and rain the following code

Public class streq {

Public static void main (String Argv []) {

Streq s = new streq ();

}

Private streq () {

String s = "marcus";

String S2 = New String ("marcus");

IF (s == s2) {

System.out.println ("We Have A Match");

} else {

System.out.println ("Not Equal");

}

}

}

1) Compile Time Error Caused by Private Constructor2) Output of "We Have A Match" 3) Output of "Not Equal" 4) Compile Time Error By Attempting to Compare Strings Using ==

Q20.given the following code, what test would you need to put in place of the comment line?

// Place Test Here

To Result in An Output of the string equal

Public class eqtest {

Public static void main (String Argv []) {

EQTEST E = New EQTEST ();

}

EQTEST () {

String s = "java";

String S2 = "java";

// Place test here {

System.out.println ("Equal");

Else

{

System.out.println ("Not Equal");

}

}

}

1) IF (S == S2) 2) IF (S.EqualsignoreCase (S2)) 4) IF (S.NocaseMatch (S2))

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC ();

INT i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT i) {} // Here

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses For the Same Method Name4) a class is prevented from accessing methods in its immediate anncestor

Q7.Which of the folloading statements are TRUE?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {

Public static void main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following codeclass Base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile Time Error Base Is A Keyword2) Compilation and No Output At Runtime3) Output of Base4) Runtime Error Base Has No Valid Constructor

Q11.What will happen when you attempt to compile and rain the Following Code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addelement (99);

3) Vector v = new vector (); v.Add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (REF R) {R.I = R.I * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.given the following class definition Which of the folloading can be leGally Placed After the comment line //th?

Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void afancymethod () {

System.out.println ("What a Fancy Method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC (); int i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses FOR THE SAME MEVEND NAME4) A Class Is Prevented from Accessing Methods in ITS IMMEDIATE ANCESTORQ7.WHICH OF THE FOLLOWING STATEments Are True?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {

Public static void main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following code

Class base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile time error Base is a keyword2) Compilation and no output at runtime3) Output of Base4) Runtime error Base has no valid constructorQ11.What will happen when you attempt to compile and run the following code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addelement (99);

3) Vector v = new vector (); v.Add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (Ref r) {

R.I = r.i * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.given the following class definition Which of the folloading can be leGally Placed After the comment line //th?

Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public class rid {

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void AfancyMethod () {system.out.println ("what a fancy method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 5 - Objects and Classes

Q1.given the folowing code

Class Base {}

Class Agg Extends Base {

Public string getfields () {

String name = "agg";

Return Name;

}

}

Public class avf {

Public static void main (String Argv []) {

Base a = new Agg ();

// hERE

}

}

What Code Placed After The Comment // Here Will Result In Calling The getfields method resulting in the output of the string "agg"?

1) System.out.println (A.Getfields ()); 2) System.out.println (a.name); 3) System.out.println ((BASE) A.Getfields ()); 4) System. Out.println ((AGG) a) .Getfields ());

Q2.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run THE FOLLOWING CODE?

Public class inc

Public static void main (String Argv []) {

INC = New INC ();

INT i = 0;

Inc.fermin (i);

i = i ;

System.out.println (i);

}

Void Fermin (INT i) {

i ;

}

}

1) Compile Time Error2) Output of 13) Output of 14) Output of 0

Q3.WHAT WILL HAPPEN WHEN You Attempt TO Compile and Run THE FOLLOWING CODE?

Class base {

Base () {

System.out.println ("Base");

}

}

Public class checket extends base {

Public static void main (String Argv []) {

Checket c = new checket ();

Super ();

}

CHECKET () {

System.out.println ("Checket");

}

1) Compile Time Error2) Checket Followed by Base3) Base Followed by Checket4) Runtime Error

Q4.Which of the following statements are TRUE?

1) A method can not be overloaded to be less public in a child class2) To be overridden a method only needs the same name and parameter types3) To be overridden a method must have the same name, parameter and return types4) An overridden method must Have The Same Name, Parameter Names and Parameter Types

Q5.given the folowing class definition

Public class upton {

Public static void main (String Argv []) {

}

Public void Amethod (INT I) {}

// hERE

}

Which of the following would Be Legal to Place After the Comment // Here? 1) Public Int Amethod (int Z) {} 2) Public Int Amethod (INT I, INT J) {Return 99;} 3) Protected Void Amethod LONG L) {} 4) private void anothermethod () {}

Q6.Which of The Following Most Closely Describes The Process Of Overriding?

1) A class with the same name replaces the functionality of a class defined earlier in the hierarchy2) A method with the same name completely replaces the functionality of a method earlier in the hierarchy3) A method with the same name but different parameters gives multiple uses For the Same Method Name4) a class is prevented from accessing methods in its immediate anncestor

Q7.Which of the folloading statements are TRUE?

1) The default constructor has a return type of void2) The default constructor takes a parameter of void3) The default constructor takes no parameters4) The default constructor is not created if the class has any constructors of its own

Q8.WHAT WILL HAPPEN WHEN You Attempt To Compile And Run The Following Class?

Class base {

Base (INT i) {

System.out.println ("Base");

}

}

Class Severn Extends Base {Public Static Void Main (String Argv []) {

Severn s = new severn ();

}

Void severn () {

System.out.println ("severn");

}

}

1) Compilation and outprut of the string "severn" at runtime2) compile time error3) Compilation and no output at runtime4) Compilation and output of the string "base"

Q9.Which of The Following Statements Are True?

1) Constructors can not have a visibility modifier2) Constructors can be marked public and protected, but not private3) Constructors can only have a primitive return type4) Constructors are not inherited Q10.What will happen when you attempt to compile and run the following code

Class base {

Public void base () {

System.out.println ("Base");

}

}

PUBLIC CLASS in Extends Base {

Public static void main (String Argv []) {

I = new in ();

}

}

1) Compile Time Error Base Is A Keyword2) Compilation and No Output At Runtime3) Output of Base4) Runtime Error Base Has No Valid Constructor

Q11.What will happen when you attempt to compile and rain the Following Code

Class base {

Private void amethod (int ibase) {

System.out.println ("BASE.AMETHOD");

}

}

Class over extends base {

Public static void main (String Argv []) {

Over o = new over ();

INT IBASE = 0;

O. AMETHOD (IBASE);

}

Public void amethod (int IOVER) {

System.out.println ("over.amethod");

}

}

1) Compile Time Error Complaining That Base.Amethod Is Private 2) Runtime Error Complaining That Base.Ameth I Private 3) Output of "Base.Amethod" 4) Output of "over.amethod"

Q12.Which of the following will success create an instance of the vector class and add an element?

1) Vector v = new vector (99); v [1] = 99;

2) Vector v = new vector (); v.addeElement (99); 3) Vector v = new vector (); v.add (99);

4 vector v = new vector (100); v.addelement ("99");

Q13.WHAT WILL HAPPEN WHEN You TRY COMPILING AND RUNNING THIS CODE?

Public class ref {

Public static void main (String Argv []) {

Ref r = new ref ();

R.AMethod (r);

}

Public void Amethod (Ref r) {

INT i = 99;

MULTI (R);

System.out.println (i);

}

Public void Multi (Ref r) {

R.I = r.i * 2;

}

}

1) Error At Compile Time 2) An Output of 99 3) An Output of 198 4) An Error At Runtime

Q14.Given the folowing code how could you invoke the base constructor That Will Print Out the string "base constructor";

Class base {

Base (INT i) {

System.out.println ("Base Constructor");

}

Base () {

}

}

Public Class Sup Extends Base {

Public static void main (String Argv []) {

Sup s = new sup ();

// one

}

SUP ()

{

// TWO

}

Public void derived ()

{

// Three

}

}

1) on the line after // one put base (10); 2) on the line after // one put super (10); 3) on the line after // Two Put Super (10); 4) on the line After // Three Put Super (10);

Q15.Which of the following methods can be leGally INSERTED in place of the comment //Method here?

Class base {

Public void Amethod (INT I) {}

}

Public class scope extends base {

Public static void main (String Argv []) {

}

// Method Here

}

1) Void Amethod (INT i) THROWS Exception {} 2) Void Amethod (long i) throws exception {} 3) Void Amethod (long i) {} 4) Public void Amethod (INT i) THROWS Exception {}

Q16.Which of The Following Methods Are Me MEMBERS OF THE Vector Class and Allow You to Input A New Element

1) Addelement2) INSERT3) APPEND4) AddItem

Q17.Given the following class definition which of the folloading can be legally placed after the comment line // here? Class base {

Public Base (INT I) {}

}

Public class myover extends base {

Public static void main (string arg []) {

Myover M = New Myover (10);

}

Myover (int i) {

Super (i);

}

Myover (String S, INT I) {

THIS (i);

// hERE

}

}

1) Myover M = New Myover (); 2) Super (); 3) This ("Hello", 10); 4) Base B = New Base (10);

Q18.Given the following class definition

Public class rid {

Public Void Amethod (INT I, STRING S) {}

// hERE

}

1) Public void Amethod (String S, INT I) {} 2) Public int AMethod (INT I, STRING S) {} 3) Public Void Amethod {} 4) Public Void Amethod (INT i String s) {}

Q19.WHAT HAPPENS WHEN You Attempt TO Compile and Run THESE TWO FILES IN THE SAME DIRECTORY?

// file p1.java

Package mypackage;

Class P1 {

Void afancymethod () {

System.out.println ("What a Fancy Method");

}

}

// file p2.java

Public Class P2 Extends P1 {

Public static void main (String Argv []) {

P2 p2 = new p2 ();

P2.afancymethod ();

}

}

1) Both Compile and P2 Outputs "What A Fancy Method" When Run2) Neither Will Compile3) Both Compile But P2 Has An Error At Run Time4) P1 Compiles Cleanly But P2 Has An Error At Compile Time

Q20.Which of the folding area? 1) item2) iesmpty3) TOARRAY4) SETTEXT

Module 6 - Advanced Language FeaturesQ1.What will happen when you attempt to compile and run the following code.public class Pvf {static boolean Paddy; public static void main (String argv []) {System.out.println (Paddy);} } 1) Compile time error2) compilation and output of false3) compilation and output of true4) compilation and output of nullQ2.What will happen when you attempt to compile and run the following codeclass Base {protected int i = 99;} public class Ab {Private INT i = 1; public static void main (string argv []) {ab a = new ab (); a.hallow ();} Abstract void Hallow () {system.out.println ("Claines" i );}} 1) Compile time error2) Compilation and output of Claines 993) Compilation and output of Claines 14) Compilation and not output at runtimeQ3.Given the following codeclass Base {static int oak = 99;} public class Doverdale extends Base { Public static void main (string argv []) {DOVERDALE D = New Doverdale (); D. AMETHOD ();} public void AMETHOD () {// Here}} Which of the fol, means, will compile and model, will compile and modify the value of the variable oak? 1) Super.oak = 1; 2) Oak = 33; 3) Base .OAK = 22; 4) OAK = 50.1;

Q4.Which of the following statements are true? 1) A method in an interface must not have a body2) A class may extend one other class plus at most one interface3) A class may extends at most one other class plus implement many interfaces4) via class accesses an interface An the keyword usesQ5.Which of the following statements are true? 1) static methods do not have access to the implicit variable called this2) A static method may be called without creating an instance of its class3) A static method may not be overriden to be non-static4) A static method may not be overloadedQ6.Given the folowing classes which of the following will compile without error? interface iFace {} class CFace implements iFace {} class Base {} public class ObRef extends Base {Public static void main (string argv []) {obref ob = New obref (); base b = new base (); object o1 = new object (); ifce o2 = new cface ();}} 1) O1 = O2; 2) b = ob; 3) OB = B; 4) O1 = B; Q7.Given the Following Code

Class Base {}

Public class mycast extends base {

Static Boolean B1 = FALSE;

Static Int i = -1;

Static Double D = 10.1;

Public static void main (String Argv []) {

Mycast m = new mycast ();

Base b = new base ();

// hERE

}

}

Which of the following, if infrest at the copy to compile and run withoutow the code = m; 2) m = b; 3) D = i; 4) b1 = i;

Q8.What will happen when you attempt to compile and rain the folowing code with the command line "Hello there"

Public class arg {

String [] myarg;

Public static void main (String Argv []) {

Myarg = argv;

}

Public void amethod () {

System.out.println (Argv [1]);

}

}

1) Compilation Time Error2) Compilation and Output of "Hello" 3) Compilation and Output of "There" 4) NONE OF THE ABOVEQ9.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run this code?

Class base {

Abstract public void myfunc ();

Public void another () {

System.out.println ("ANOTHER METHOD");

}

}

Public class abs Extends base {

Public static void main (String Argv []) {

ABS A = New ABS ();

a.amethod ();

}

Public void myfunc () {

System.out.println ("My FUNC");

}

Public void amethod () {

Myfunc ();

}

}

1) The code will compile and run, printing out the words "My Func" 2) The compiler will complain that the Base class is not declared as abstract.3) The code will compile but complain at run time that the Base class has non Abstract methods4) The Compiler Will Complain That The Method Myfunc in The Base Class Has No Body, Nobody At All to Look IT

Q10.WHAT WILL HAPPEN WHEN You Attempt To Compile and Run this code?

Abstract class base {

Abstract public void myfunc ();

Public void another () {

System.out.println ("ANOTHER METHOD");

}

}

Public class abs Extends base {

Public static void main (String Argv []) {

ABS A = New ABS ();

a.amethod ();

}

Public void myfunc () {

System.out.println ("My FUNC");

}

Public void amethod () {

Myfunc ();

}

}

1) The code will compile and run, printing out the words "My Func" 2) The compiler will complain that the Base class has non abstract methods3) The code will compile but complain at run time that the Base class has non abstract methods4) The Compiler Will Complain That The Method Myfunc in The Base Class Has No Body, Nobody At All to Look IT

Q1.given the folowing code

Import java.io. *;

PUBLIC CLASS PPVG {

Public static void main (string argv []) {ppvg p = new PPVG ();

p.fliton ();

}

Public int fliton () {

Try {

FileInputStream DIN = New FileInputStream ("ppvg.java");

DIN.READ ();

} catch (ioexception ie) {

System.out.println ("flytwick");

Return 99;

} finally {

System.out.println ("Fliton");

}

Return -1;

}

}

Assuming the file ppvg.java Is Available To Be Read Which of The Following Statements Are True if you try??

1) The program will run and output only "flytwick" 2) The program will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because The Method fliton attempts to return Two Values

Q2.What will happen when you attempt to compile and rain the Following Code

Import java.io. *;

Class base {

Public void amethod () throws filenotfoundexception {}

}

Public class excepdemo extends base {

Public static void main (String Argv []) {

ExcepDemo E = New ExcepDemo ();

}

Public void amethod () {}

protected excepdemo () {

Try {

DataInputStream DIN = New DataInputStream (System.in);

System.out.println ("PAUSING");

DIN.READBYTE ();

System.out.println ("Continuing");

THIS.AMETHOD ();

} catch (ioexception ie) {}

}

}

1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hit

Q3.You Wei To Find Out The Value of The Last Element of an Array. You WRITE The FOLLOWING CODE. What WILL HAPPEN WHEN You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q4.given The Following Code

Import java.io. *;

Public Class TH {

Public static void main (String Argv []) {

TH t = new TH ();

T.amethod ();

}

Public void amethod () {

Try {

Iocall ();

} catch (ioexception ie) {}

}

}

What Code Would Be Most Likey for the Body of The Iocall Method

1) Public void ocall () throws oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

2) public void ocall () throw oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

3) Public void ocall () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

4) Public void ocall throws oews oException () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

Q5.WHAT WILL Be Output if you try to compile and rain the following code, but there is no file called hello.txt in the current directory?

Import java.io. *;

Public class mine {

Public static void main (String Argv []) {

Mine m = new mine ();

System.out.println (M.AMethod ());

}

Public int athod () {

Try {

FileInputStream DIS = New FileInputStream ("Hello.txt");

} catch (filenotfoundexception fne) {

System.out.println ("No Such File");

Return -1;

} catch (ioexception ie) {

} finally {

System.out.println ("Doing Finally");

}

Return 0;

}

}

1) No Such File Found 2 No Such Found, -1 3) No Such File Found, Doing Finally, -1 4) 0

Q1.given the folowing code

Import java.io. *;

PUBLIC CLASS PPVG {

Public static void main (string argv []) {ppvg p = new PPVG ();

p.fliton ();

}

Public int fliton () {

Try {

FileInputStream DIN = New FileInputStream ("ppvg.java");

DIN.READ ();

} catch (ioexception ie) {

System.out.println ("flytwick");

Return 99;

} finally {

System.out.println ("Fliton");

}

Return -1;

}

}

Assuming the file ppvg.java Is Available To Be Read Which of The Following Statements Are True if you try??

1) The program will run and output only "flytwick" 2) The program will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because The Method fliton attempts to return Two Values

Q2.What will happen when you attempt to compile and rain the Following Code

Import java.io. *;

Class base {

Public void amethod () throws filenotfoundexception {}

}

Public class excepdemo extends base {

Public static void main (String Argv []) {

ExcepDemo E = New ExcepDemo ();

}

Public void amethod () {}

protected excepdemo () {

Try {

DataInputStream DIN = New DataInputStream (System.in);

System.out.println ("PAUSING");

DIN.READBYTE ();

System.out.println ("Continuing");

THIS.AMETHOD ();

} catch (ioexception ie) {}

}

}

1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hit

Q3.You Wei To Find Out The Value of The Last Element of an Array. You WRITE The FOLLOWING CODE. What WILL HAPPEN WHEN You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q4.given The Following Code

Import java.io. *;

Public Class TH {

Public static void main (String Argv []) {

TH t = new TH ();

T.amethod ();

}

Public void amethod () {

Try {

Iocall ();

} catch (ioexception ie) {}

}

}

What Code Would Be Most Likey for the Body of The Iocall Method

1) Public void ocall () throws oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

2) public void ocall () throw oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

3) Public void ocall () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

4) Public void ocall throws oews oException () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

Q5.WHAT WILL Be Output if you try to compile and rain the following code, but there is no file called hello.txt in the current directory?

Import java.io. *;

Public class mine {

Public static void main (String Argv []) {

Mine m = new mine ();

System.out.println (M.AMethod ());

}

Public int athod () {

Try {

FileInputStream DIS = New FileInputStream ("Hello.txt");

} catch (filenotfoundexception fne) {

System.out.println ("No Such File");

Return -1;

} catch (ioexception ie) {

} finally {

System.out.println ("Doing Finally");

}

Return 0;

}

}

1) No Such File Found 2 No Such Found, -1 3) No Such File Found, Doing Finally, -1 4) 0

Q1.given the folowing code

Import java.io. *;

PUBLIC CLASS PPVG {

Public static void main (string argv []) {ppvg p = new PPVG ();

p.fliton ();

}

Public int fliton () {

Try {

FileInputStream DIN = New FileInputStream ("ppvg.java");

DIN.READ ();

} catch (ioexception ie) {

System.out.println ("flytwick");

Return 99;

} finally {

System.out.println ("Fliton");

}

Return -1;

}

}

Assuming the file ppvg.java Is Available To Be Read Which of The Following Statements Are True if you try??

1) The program will run and output only "flytwick" 2) The program will run and output only "fliton" 3) The program will run and output both "fliton" and "flytwick" 4) An error will occur at compile time because The Method fliton attempts to return Two Values

Q2.What will happen when you attempt to compile and rain the Following Code

Import java.io. *;

Class base {

Public void amethod () throws filenotfoundexception {}

}

Public class excepdemo extends base {

Public static void main (String Argv []) {

ExcepDemo E = New ExcepDemo ();

}

Public void amethod () {}

protected excepdemo () {

Try {

DataInputStream DIN = New DataInputStream (System.in);

System.out.println ("PAUSING");

DIN.READBYTE ();

System.out.println ("Continuing");

THIS.AMETHOD ();

} catch (ioexception ie) {}

}

}

1) Compile time error caused by protected constructor2) Compile time error caused by amethod not declaring Exception3) Runtime error caused by amethod not declaring Exception4) Compile and run with output of "Pausing" and "Continuing" after a key is hit

Q3.You Wei To Find Out The Value of The Last Element of an Array. You WRITE The FOLLOWING CODE. What WILL HAPPEN WHEN You Compile and Run It.?

Public class myar {

Public static void main (String Argv []) {

Int [] i = new int [5];

System.out.println (i [5]);

}

}

1) An error at company Time3) The value 0 Will Be Output4) The string "null" Will Be Output

Q4.given The Following Code

Import java.io. *;

Public Class TH {

Public static void main (String Argv []) {

TH t = new TH ();

T.amethod ();

}

Public void amethod () {

Try {

Iocall ();

} catch (ioexception ie) {}

}

}

What Code Would Be Most Likey for the Body of The Iocall Method

1) Public void ocall () throws oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

2) public void ocall () throw oException {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

3) Public void ocall () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

4) Public void ocall throws oews oException () {

DataInputStream DIN = New DataInputStream (System.in);

DIN.READCHAR ();

}

Q5.WHAT WILL Be Output if you try to compile and rain the following code, but there is no file called hello.txt in the current directory?

Import java.io. *;

Public class mine {

Public static void main (String Argv []) {

Mine m = new mine ();

System.out.println (M.AMethod ());

}

Public int athod () {

Try {

FileInputStream DIS = New FileInputStream ("Hello.txt");

} catch (filenotfoundexception fne) {

System.out.println ("No Such File");

Return -1;

} catch (ioexception ie) {

} finally {

System.out.println ("Doing Finally");

}

Return 0;

}

}

1) No Such File Found 2 No Such Found, -1 3) No Such File Found, Doing Finally, -1 4) 0

Module 8 - Building Guis

Module 9 - The AWT Event Model

Module 10 - The AWT Component LibraryModule 11 - Java Foundation Classes

Q1.You area Creating An Application That Has A Form With a Text Entry Field Used to Enter a Persons Age. Which of the Following IS Appropriate for Capturing this Information.

1) Use the Text field of a TextField and parse the result using Integer2) Use the getInteger method of the TextField3) Use the getText method of a TextBox and parse the result using the getInt method of Integer class4) Use the getText method of a TextField And use the parseint method of the integer class

Q2.Which of The Following Statements Are True?

1) The default layout manager for an Applet is FlowLayout2) The default layout manager for a Frame is FlowLayout3) A layout manager must be assigned to an Applet before the setSize method is called4) The FlowLayout manager attempts to honor the preferred size of any components

Q3.Which of the following area?

1) A component may have only one event listener attached at a time2) An event listener may be removed from a component3) The ActionListener interface has no corresponding Adapter class4) The processing of an event listener requires a try / catch block

Q4.What will happen when you attempt to compile and rain this code

// Demonstration of Event HANDLING

Import java.awt. *;

Import java.awt.event. *;

Public class mywc extends frame imports windowlistener {

Public static void main (String Argv []) {

MYWC MWC = New MYWC ();

}

Public void windowclosing (windowevent wE) {

System.exit (0);

} // end of windowClosing

Public void mywc () {

Setsize (300, 300);

SetVisible (TRUE);

}

} // End of class

1) Error at compile time2) Visible Frame created that that can be closed3) Compilation but no output at run time4) Error at compile time because of comment before import statementsQ5.What most closely matches the appearance when this code runs?

Import java.awt. *;

Public class company extends frame {

Public static void main (String Argv []) {

CompLay Cl = New Complay ();

}

Complay () {

PANEL P = new panel ();

P.SetBackground (Color.pink);

P.ADD (New Button ("one"));

P.ADD (New Button));

P.ADD (New Button ("Three"));

Add ("South", P);

SetLayout (New FlowLayout ());

Setsize (300, 300);

SetVisible (TRUE);

}

}

1) The buttons will run from left to right along the bottom of the Frame2) The buttons will run from left to right along the top of the frame3) The buttons will not be displayed4) Only button three will show occupying all of the frame

Q6.how do you change The Current Layout Manager for a Container

1) Use the setLayout Method2) ONCE CREATED You Cannot Change The Current Layout Manager of a Component3) Use The setTlayoutManager Method4) Use the UpdateLayout Method

Q7.how do you indeicate where a company?

1) North, South, East, West2) Assign a Row / Column Grid Reference3) Pass A X / Y Percentage Parameter To The Add Method4) Do Notning, The FlowLayout Will Position The Component

Q8.given The Following Code

Import java.awt. *;

Public class setf extends frame {

Public static void main (String Argv []) {

Setf s = new setf ();

S.setsize (300, 200);

S.SetVisible (TRUE);

}

}

How Could You Set The Frame Surface Color To Pink

1) s.SetBackground; 2) s.SetColor (PINK); 3) S.background (PINK); 4) S.COLOR = Color.pink

Q9.WHAT WILL BE Displayed When You Attempt To Compile and Run The Following Code // Code Start

Import java.awt. *;

Public class butt extends frame {

Public static void main (String Argv []) {

Butt mybut = new butt ();

}

Butt () {

Button hellobut = New Button ("Hello");

Button Byebut = New Button ("BYE");

Add (Hellobut);

Add (Byebut);

Setsize (300, 300);

SetVisible (TRUE);

}

}

// code end

1) Two buttons side by side occupying all of the frame, Hello on the left and Bye on the right 2) One button occupying the entire frame saying Hello 3) One button occupying the entire frame saying Bye 4) Two buttons at the top of The frame one saying hello the Other Saying Bye

Q10.An Applet Has Its Layout Manager set to the default of flowLayout. What code would be Correct to change to another layout manager.

1) setLayoutManager (New GridLayout ()); 2) SetLayout (2, 2)); 3) SetGridLayout (2, 2); 4) SetBorderLayout ();

Module 1 - Getting Started

Q1.4

Q2.23

Q3.1

Q4.2

Q5.4

Moudle2

Module 1 - Getting Started

Q1.4

Q2.23

Q3.1

Q4.2

Q5.4

Moudle2

Module 1 - Getting Started

Q1.4

Q2.23

Q3.1

Q4.2

Q5.4

Moudle2

Q1.124

Q2.2

Q3.34

Q4.4

Q5.4

Q6.14

Q7.5

Q8.1

Q9.1345

Q10.2345

Module 3 - Expressions and Flow Control

Q1.3

Q2.2

Q3.23

Q4.123

Q5.3

Q6.1

Q7.4

Q8.1

Q9.4

Q10.24

Q11.4

Q12.2

Q13.14

Q14.2

Q15.3

Q16.2

Q17.23

Q18.1

Q19.3

Q20.3

Module 4 - Arrays

Q1.4

Q2.3

Q3.4

Q4.2

Q5.2

Module5

1.4

2.4

3.1

4.3

5.234

6.2

7.34

8.2

9.4

10.2

11.4

12.4

13.1

14.3

15.23

16.1

17.4

18.14

19.4

20.123

Module6

转载请注明原文地址:https://www.9cbs.com/read-43791.html

New Post(0)