solved java

Upload: abhishek-johari

Post on 11-Feb-2018

227 views

Category:

Documents


0 download

TRANSCRIPT

  • 7/23/2019 Solved Java

    1/28

    1) In OOP, the concept of insulating data and from direct access by the program isknown as

    a) Data hiding>>b) Inheritancec) Polymorphismd) Abstraction2) Which of the following is NOT True with respect to OOPa. Upgrading systems is difficultb. Multiple objects co-exists without any interferencec. Secure Programs can be builtd. Software development is made easy>>3) What are Byte code instructionsa. It is Java Source Codeb. It is code created by Java Compiler from the Source code>>c. It is machine code generated by interpreterd. It is executable code generated by the compiler4) Which of the following HTML tag is used to communicate Java with a web pagea. HTMLb. APPLET>>c. CODEd. HEAD5) Which of the following is NOT one of the jump statements not available in Javaa. Goto>>b. breakc. continued. return6) What should be the source filename of a Java filea. Any nameb. name matching any class name present in source filec. name matching the first class name in the source filed. name of the class containing the main method >>7) What will be the output of the following code, if executed with command line arguments

    as follows

    javacmdline Java is wonderful

    classcmdline

    {

    public static void main(String args[)

    {

    for(inti=1;i

  • 7/23/2019 Solved Java

    2/28

    System.out.print( );

    }

    System.out.println();

    }

    }

    a. Javab. Java isc. is wonderful>>d. cmdline Java is wonderful8) Which of the following is the maximum absolute value for a signed intDatatypea. 127>>b. 32768c. 32767d. 2147489) What is FALSE with respect to variable in Javaa. A variable must be declared before it is used in the programb. A variable can be used to store any data typec. The place of declaration decides the scope of the variabled. A variable name must be maximum 10 characters long10)What is the value of the expression Math.floor(1.567)a. 1.6b. 1c. 2>>d. 1.511)What is the value of the expression 14-3*2/3a. 1b. 12 >>c. 7d. 212)What is the value of result if the code of statements are executed

    int result = 42+45-48-5-15+20*2;

    a. 59 >>b. 68c. 146d. 13413)Which of the following is conditional operator available in Javaa. &&b. ?: >>c. ::d. >c. 6d. 9,1015)Consider the following program code. state the output from itclassifif

    {

    public static void main(String args[)

    {

    int x=3, y=1,z=5;

    if(x>y)

    {

    if (zz)

    {

  • 7/23/2019 Solved Java

    4/28

    System.out.println(y is greater than z);

    }

    }

    }

    }

    a) z is greater than yx is greater than y

    b) y is greater than zx is greater than y

    c) x is greater than yx is greater than z

    d) x is greater than y>>z is greater than y>>

    16)Which of the following looping constructs body, will execute at least once even if thecondition is false.

    a. forb. doc. whiled. none of the above.>>17)What will be the output of the following code segmentint r=20;

    while(r>0)

    {

    r=r-10;

    if(r>0)

    continue;

    System.out.print("r is "+r);

    }

    a. r is 10b. r is 0>>c. r is 20d. r is 20 r is 1018)Variables whose values can never be changed are called asa. static variables

  • 7/23/2019 Solved Java

    5/28

    b. Final variablesc. object variablesd. Abstract variables >>19)What is NOT TRUE about static variablea. There are created by giving keyword static.b. only one copy of static variable is created for all instances of class.c. It must be accessed using object of class >>d. These are referred to as class variables.20)Consider the following class definition. Identify the error in the code

    class cube

    {

    private cube() { }

    intcalc(int s)

    {

    return s*s*s;

    }

    };

    class sample

    {

    public static void main(String args[)

    {

    cube c=new cube();

    intcb=c.calc(3);

    System.out.print(cb);

    }

    }

    a. Default constructor cannot have access modifier privateb. class sample is not publicc. class cube is not public>>d. method calc not written completely21)Which String method is used to compare 2 strings considering any casea. Equals () >>b. equaltoc. equalsIgnoreCased. equalscase()22)Which of the following is NOT a method of Vector classa. addElementb. elementAtc. editElement>>d. insertElement

  • 7/23/2019 Solved Java

    6/28

    23)To create a package what is the first statement included?a. import java.aw+.*;b. package >>c. publicd. class24)In the Interface definition what is TRUE for method declaratione. List of methods declaration is only done>>a. Method declaration as well as bodyb. Only one Method declaration can be donec. Only one Methods body is allowed25)What classes does the Java system package java.util containa. Classes for primitive types,Strings,Math functions, Threads and Exceptionsf. Classes such as Vectors, hash tables, random numbers, date etc>>b. Classes for Input/Output supportc. Classes for implementing graphical user interface26)What does the following import statement actually mean import java.awt.*;a. import awt class from the java packageb. Import all variables from awt classg. Import all the classes from the awt package contained in the java package>>c. Import all the classes from the java package27)In Multithreaded programming, which method is used to return the threads to

    runnable state fromthe wait state

    a. notify()h. resume()>>b. start()c. runnable()28)In Java when a compile-time error occurs, then which file is NOT createda) sourceb) .javac) .classi. .exe >>29)In Java, when a run-time error occurs which of the following may happena. compiles successfullyb. produces wrong outputc. abnormal termination

    j. All of the above>>30)Which exception may be thrown if the given code is executed giving 2 integer runtime

    arguments

    class sample

    {

    public static void main(String args[){

    try

  • 7/23/2019 Solved Java

    7/28

    {

    int a=Integer.parseInt(args[0);

    int b=Integer.parseInt(args);

    int c = a + b;

    System.out.println("Sum is "+c);

    }

    catch(ArithmeticExceptionae)

    { System.out.println("Arithmetic Exception "+ae.getMessage()); }

    catch(NumberFormatException ne)

    { System.out.println("Number Format Exception "+ne.getMessage()); }

    catch(Exception e)

    { System.out.println("Exception "+e); }

    }

    }

    a. ArithmeticExceptionb. NumberFormatExceptionc. Exceptionk. None of the above>>31)What does message passing involve in OOPa. It involves specifying name of the objectb. It involves name of the methodc. It involves the information to be sentl. All of the options 1,2,3 >>32)Which of the following is TRUE with respect to Dynamic Bindinga. Linking of a procedure call to the code to be executed in response to the callm. Code associated with a given procedure is not know until time of the call at run time>>b. It is associated with inheritance and polymorphismc. All of the options 1,2,333)JSL stands fora. Java Source Linkern. Java Standard Library>>b. Just Source Libraryc. Java Standard Linker34)JDK stands fora. Java Display Kitb. Java Direct Kitc. Java Debugger Kito. Java Development Kit>>

  • 7/23/2019 Solved Java

    8/28

    35) Which of the following type of Programs can be developed in Java

    a. Standalone applicationsb. Web appletsp. Both Option1and Option 2>>c. Neither Option1and Option 235)Which of the following is NOT the tokens available in Java languagea. Reserved keywordsb. Operatorsq. Classes>>c. Separators36)Which of the following is NOT a valid assignment statementa. a=b=c=0;r. a='a'>>b. 0=b;c. c=72.2537)Which of the following operator is used to access the instance variables and methods of

    class objets

    a) .b) :c) ::s. instanceOf>>38)What will be the value of b if a=2 and given the expression b=a++;a. 0b. 1c.

    2t. 3>>

    39)What is the value of ans if the code of statements are executedinti = 42+45-48-5;

    int j = 5+5-8+2;

    intans = i%j;

    u. 2 >>a. 8b. 34c. 1240)Which of the following statements do not fall in selection statement categorya. if statementb. switch statementv. conditional operator statement>>c. for construct statement41)What will be the output of the following code segment

    inta,b;

    a=2;

    b=5;

  • 7/23/2019 Solved Java

    9/28

    if(a>2)

    if(b>2)

    {

    System.out.print(b is +b);

    }

    else

    System.out.print(a is +a);

    a. a is 2b. b is 5c. a is 2 followed by b is 5w. No output >>42)Which of the following form of Inheritance has one super class and many subclasses.a. Single Inheritanceb. Multilevel Inheritancex. Hierarchical Inheritance>>c. Multiple Inheritance43)When default keyword is used a member of a class, how is the visiblility of the membera. It is visible everywhereb. It is visible everywhere in the current package and also subclasses in other packagesy. It is visible everywhere in the current package only>>c. It is visible only in its own class44)

    What is wrong in the following code

    abstract class print

    {

    abstract show();

    }

    class display extends print

    {

    }

    a. Nothing is wrongz. Method show() should have a return type>>b. Method show() is not implemented in class displayc. class display does not contain anything45)The method removeElement(argument) is a method used witha. Arrays>>b. Stringsc. StringBuffersd.

    Vectors>>

    46)What statement would better explain what are wrapper classesaa.Wrapper classes convert primitive datatypes into object types>>a. Wrapper classes convert objects to primitive data types

  • 7/23/2019 Solved Java

    10/28

    b. Wrapper classes are used to store list of objects that may vary in sizec. Wrapper classes are used to convert any class type into array type object47)What is valid statement to import only the class color from the awt package contained

    in the javapackage

    a. awt.java.*;b. awt.java.color;bb.java.awt.color; >>c. java.awt.*;48)The following statements create what type of inheritance if class B and class C are Base

    classes

    class A extends B extends C

    {

    }

    a. Single Inheritanceb. Multilevel Inheritancecc. Multiple Inheritance >>c. Hierarchical Inheritance49)Which of the following step is invalid for creating a packagea. Declare the package in beginning of the fileb. Define the classes to be put in the package & declare it publicc. Create the listing as java in the Subdirectory by package menudd.Execute this java file>>50)In Multithreaded programming, which method is to be implemented when thread are

    created by implementing the 'Runnable' interface

    ee. start()>>a. run()b. init()c. stop()51)In, Java Exception handling code how many catch statements can a try havea. noneb. onec. twoff. one or more>>52)In Java, which Exception type is caused when an applet tries to perform an action not

    allowed by thebrowsers security setting

    a. ObjectOutOfBoundsExceptionb. OutOfMemoryExceptiongg.BrowserAccessException>>c. SecurityException53)What are user define data types and behave like built-in types of a programming

    language.

    a) Objects

  • 7/23/2019 Solved Java

    11/28

    b) Methodsc) Templates

    hh.Classes>>

    54)In OOP, the concept of wrapping data and methods into a single unit called classes isknown as

    a.

    Data Abstractionb. Inheritancec. Polymorphism

    ii. Encapsulation>>55)In OOP, the concept of Inheritance provides us with

    a. Insulationjj. Linking >>

    b. Reusabilityc. Sharing

    56)In OOP process by which objects of one class acquire the properties of objects ofanotherclass is

    kk.Inheritance >>a. Polymorphismb. Encapsulationc. Abstraction

    57)In OOP the concept of representing essential features without including the backgrounddetails is called as

    a. Data Hidingll. Data Abstraction >>

    b. Inheritancec. Dynamic Binding

    58)Dynamic binding is associated withmm. Polymorphism>>

    a. Inheritanceb. Both Option1 and Option2c. Neither Option1 and Option2

    59)In OOP approach programs are divided intoa. Objects

    b. Methodsnn.Functions >>

    c. Procedures60)In OOP program objects communicate with each other through

    a. Datab. Methodsc. Classes

    oo.Objects>>

    61)Which of the following is NOT one of the programming techniques.a. Structured programming

    pp.Modular programming >>

  • 7/23/2019 Solved Java

    12/28

    b. Bottom-up programmingc. Destructred programming

    62)In OOP, the concept of Polymorphism isa. Reusability

    qq.Ability to take more than one form >>b. Sharing of datac. Hiding of data

    63)OOP treats what as a critical element in program development and does not allow it toflow freely around the system.

    a. Proceduresb. Actionc. Data

    rr. Method>>

    64)Which of the following type of applications OOP can be useful for

    ss. Real-time Systems >>a. Simulation and modellingb. Decision Support and office automation systemsc. All of the options 1,2,3

    65)Which of the following C++ feature is NOT included in Javaa. Multilevel inheritance

    tt. Inner classes >>b. Multithreadingc. Operator overloading

    66)Which of the following tools is NOT a part of JDK (Java Development Kit)uu.appletviewer ( for viewing applets) >>

    a. javac ( java compiler)b. javac ( java compiler)c. classes and methods

    67)What is HotJavavv.It is first program written in Java and is web browser >>

    a. It is applet to run a browserb. It is network application to run appletsc. It is program that can edit applets

    68)Java is Distributed-language, What statement explain this featurea. Java programs can be easily moved from one computer system to anotherb. Java systems verify memory access and virus

    ww. Java can be used to create applications on the networks >>c. It provides many safeguards to ensure reliable code

    69)Java is Multithreaded Language, What Statement best explains this featurea. Java application need not wait for the application to finish one task before

    beginning another >>

    b. Java is capable of dynamically linking in U class libraries, methods and objectsc. Java supports functions written in other languages such as C and C++d. Java uses less amount of memory in environment

  • 7/23/2019 Solved Java

    13/28

    70)API stands fora. Applet Program Internetb. Application Package Informationc. Abstract Programming Interfaced. Application Programming Interface>>

    71)What does JVM stands fora. Java Virtual Machine>>b. Java Visual Memoryc. Jar Visual Monitoringd. Java Virtual Management

    72)What is the function of Java Disassemblera. Machine code can be converted into compiled code>>b. Compiled code can be converted into machine codec. Source code can be converted into compiled coded. Compiled code can be converted into source code

    73)Which of the following feature of C++ is NOT supported by Java and isthereforeimplementedusing interfaces

    a. Nested Classesb. Inner Classes>>c. Polymorphism

    74)Java is also popularly known asa. Web browserb. Applet languagec. Internet languaged. Object language>>

    75)Java is ----- Language.a. Compiledb. Interpretedc. Both Compiled and interpreted >>d. Byte Code

    76)Java is Extensible Language,what statement explain this featurea. Java application need not wait for the application to finish one task before gegining

    another

    b. Java is capable of dynamically linking in u class libraries methods and subjects>>c. Java supports functions written in other languages such as c and c++d. Java uses less amount of memory in environment

    77)Java is Platform-independent,what statement explain this featurea. Java programs can be easily moved from one computer to another >>b. Java systems verify memory access and virousc. Java can be used to create applications on the networks>>d. It provides many safeguards to ensure reliable code

    78)To create a package what is the first statement included?a) import java.aw+.*;b) package >>c) publicd) class

  • 7/23/2019 Solved Java

    14/28

    79)What classes does the Java system package java.awt containa) Classes for primitive types,Strings,Math functions, Threads and Exceptionsb) Classes such as Vectors, hash tables, random numbers, date etcc) Classes for Input/Output supportd) Classes for implementing graphical user interface >>

    80)Which of the following step is invalid for creating a packagea) Declare the package in beginning of the fileb) Define the classes to be put in the package & declare it publicc) Create the listing as java in the Subdirectory by package menud) Execute this java file >>

    81)In Multithreaded programming, what is the constant numeric value used for settinglowestpriority for Threads

    a) 1>>b) 5c) 4d) 10

    82) In Java, which Exception type is caused by failure of conversion between strings andnumbers

    a) StringIndexOutOfBoundsExceptionb) InvalidConversionExceptionc) InvalidAccessExceptiond) NumberFormatException>>

    83)Which of the following is valid rule to create Java Identifier namesa) It can contain digits, alphabets, dollar symbol and underscore >>b) It cannot start with a underscorec) It cannot contain uppercase letterd) It can start with a digit

    84)Which of the following is NOT one of the Iteration statements available in Javaa) forb) if >>c) dod) while

    85)What is the process of assigning a smaller type to a larger one with respect to typea) castingb) Promotionc) narrowingd) implicit>>

    86)Which of the following operators have lowest precedencea) unary operatorsb) binary operatorsc) bitwise operators >> Ord) logical operators>>

    87)If the variable i& j are of type int, What is the value of j if j=i/2a) 0.5

    b) 0.2c) 0 >>d) 1

  • 7/23/2019 Solved Java

    15/28

    88)Which of the following is NOT True with respect to if & switch branching statementa) In nested if Statement the last else gets associated with the first if statementb) A switch expression can be of any data type >>c) Program terminates execution on switch with a break statementd) all of the above

    89)Which of the following is NOT one of the looping constructs available in Javaa) switchb) whilec) dod) for >>

    90)Which of the following is NOT one of the different forms of InheritanceSingle Inheritance

    Simple Inheritance >>

    Multilenceijnheritance>>

    Hierarchical Inheritance

    91)Which of the following visibility modifiers allows widest visibility and is accesibleeverywhere

    a) privateb) Protectedc) Public >>d) Friendly

    92)What does the following method do? Integer.parseInt(arg)a) converts primitive Int to wrapper classb) converts integer to small integer typec) converts string to primitive integer>>d) converts string object to wrapper Int

    93) What of the following String methods is used to join two stringsa) joinb) concat>>c) concated) concatenation

    94)What is process of converting one data type to anothera.

    Convertingb. Changing

    c. Definingd. Casting / type casting>>95)What type of value will the expression (a%b) return where, a=10 and b=7.a. 7b. 1c. Int>>d. float96)What is the value of expression a>b. 2c. 3>>d. None of these>>

  • 7/23/2019 Solved Java

    16/28

    97)What will be the output of the following program codeclass max

    {

    public static void main(String args[])

    {

    int max=10;

    max(max,10,20);

    System.out.print(max);

    }

    static void max(intmax,int x1,int x2)

    {

    if(x1>x2)

    max=x1;

    else

    max=x2;

    }

    }

    a. 10>>b. 20c.

    30d. 0

    98)Identify line numbers where logical errors occur in the following code so that factorialof 5 is calculated.

    1 class factorial

    2 {

    3 public static void main(String args[])

    4 {

    5 int n=0,fact=0;

    6 for(int n=0;n>=1;n--)

    7 fact=fact*1;8 System.out.println(Factorial of 5 is +fact);

    9 }

    10 }

    a. lines 5,6b. lines 6c. lines 7d. lines 5,6,7>>

    a) What is valid for abstract classes and abstract methodsa. We cannot use abstract classes to instantiate objects.>>b. abstract methods of an abstract class must be defined in its subclass>>.c. Constructers cannot be declared abstract >>d. All of the above >>> *99)Which of the following is an valid statement with shorhand operator //a. a1/=1b. a*=1c. a%=1d. All of the above>

    100) What is the error in the following class definitionabstract class sample

    {

    abstractcalc(int a) { }}

  • 7/23/2019 Solved Java

    17/28

    a) class header is not defined properlyb) constructor is not definedc) methodcalc is not defined properly //d) No error>>

    101) Java does not support Multiple Inheritance. What is an alternative approachprovided to implement this

    a. Packagesb. Interfaces>>c. Collectionsd. Wrapper classes102) What statement is used to include classes from packagesa. includeb. import SA>>c. extendd. interface103) In Multithreaded programming, when a thread is ready for execution and is

    waiting for the availability of the processor, it is said to be in what state

    a. runningb. newbornc. runnable >>d. blocked104) In Java, which Exception type is caused by math errorsa. ArithmeticException>>b. ArrayStoreExceptionc. NumberFormatExceptiond. IOException

    105) Which of the following is NOT a Java keyworda. Throws>>b. tryc. while>> ord. Exception106) Which of the following is NOT true with respect to Java Program Structurea. Comments can be given only at the beginning of Program>>b. Package statement should be before class definitionc. Import statement should be before class definitiond. Interface statement should be before class definition107) Which of the following are Integer types in Javaa. Byteb. Long>>c. Shortd. All of the options 1,2,3108) Which of the following is NOT one of the valid escape sequence available for use

    in Java

    a.

    \bb. \nc. \m>>d. \t

  • 7/23/2019 Solved Java

    18/28

    109) What is the value of Math.ceil(1.567)a. 1.6b. 1c. 2>>d. 1.5110) What will be the output of the following code segment

    n=5;

    r=n%3;

    if (r == 0)

    System.out.println(zero);

    else

    if (r ==1)

    System.out.println(one);

    else

    if (r == 2)

    System.out.println(two);

    else

    System.out.println(three);a. zerob. onec. two >>d. Three111) What will be the output of the following code segment

    i=11;

    sum=0;do

    {

    sum=sum+i;

    i=i+1;

    }while(i>112) Which of the statement is invaild with respect to finalizer method.a. They are used to initialize objectsb. They are used to free certain resourcesc. They can be added to any classd. Java calls this method whenever it is about to reclaim space for that objects >>113) Methods that can never be altered in any way are called asa. static methodsb. abstract methods >>c. Member methodsd. Final methods114) What will be displayed as output if S1 contains word "Java" with method

    S1.indexOf('a') //

    a. 4b. 2

  • 7/23/2019 Solved Java

    19/28

    c. 1>>d. 3115) What form of Inheritance is not supported by Javaa. Singleb. Multilevelc. Multiple>>d. Hierarchical116) What does the following import statement actually mean import java.awt.*;a. import awt class from the java packageb. Import all variables from awt classc. Import all the classes from the awt package contained in the java package>>d. Import all the classes from the java package117) In Java, which Exception type is caused when there's not enough memory to

    allocate a new object

    a. NullPointerExceptionb. ObjectOutOfBoundsExceptionc.

    OutOfMemoryException>> d. IOException

    118) In Java, which Exception type is caused by math errorsa. ArithmeticException>>b. ArrayStoreExceptionc. NumberFormatExceptiond. IOException

    119) Which of the following is invalid in case of standard default values of variablesa. byte has a default value of 0>>b. int has a default value of 0>>c. float has a default value of 0 a or cd. boolean has a default value of 0120) Which of the following is a non-primitive Data type in Javaa. Integerb. Arrays>>c. Characterd. Boolean121) What is the value of the expression 6-(3+2)*5/2a. -6 >>b. 2c. -4d. 2.5122) What will be the output of the following program code

    class max

    {

    public static void main(String args[])

    {

    int max=10;

    max(max,10,20);System.out.print(max);

    }

    static void max(intmax,int x1,int x2)

    {

  • 7/23/2019 Solved Java

    20/28

    if(x1>x2)

    max=x1;

    else

    max=x2;

    }

    }

    a. 10 >>b. 20c.

    30d. 0

    123) Given the following code segment, what will happen when break is executedfor( )

    for( )

    if(condition)

    break;

    a. It will terminate the programb. It will exit from the if >>c.

    It will exit from inner for loopd. It will exit from outer for loop

    124) What is the use of the super() method//a. It is used only with a subclass constructor.b. The call to this method must be the first statement within the subclass constructorc. The parameters of the super method must match the order and type of the instance variables declared

    in the superclassd. All of the Above>>125) Which of the following form of Inheritance has several super classes.a. Single Inheritanceb. Multilevel Inheritancec. Hierarchical Inheritanced. Multiple Inheritance>>126) [51] What will be displayed as output if S1 contains word "Java" with method

    S1.replace('a','c')

    a. vab. Jcvc>>c. Jcvad. Av127) [52] Which of the following string created is a NULL terminated.//a. String created using array of charactersb. String created using instance of String class .c. String created using instance of StringBuffer class.>>d. All of the above128) Variables defined in Interfaces are by defaulta. Final>>b. staticc. Both 1 & 2d. Neither 1 nor 2129) What statement is used to include classes from packagesa. includeb. import>>c. extend

  • 7/23/2019 Solved Java

    21/28

    d. Interface130) In Multithreaded programming, what is the constant numeric value used for

    setting highest priority for Threads

    a. 1b. 5c. 4d. 10>>131) When a run-time error occurs in Java, what happens while execution of the

    program

    a. displays an error and continues further execution of the programb. displays an error message and abnormally terminates the execution of the program>>c. executes the program generating outputd. displays compile-time errors in the program132) In Java, what is a condition that is caused by a run-time error in the programa. validityb. exception >>c. errord. Action133) In, Java user-defined Exceptions can be created using keyworda. Throw >>b. Throwsc. Thrownd. Catch134) In Java, what segment of code is is used for error handlinga. Detecting and throwing Execptionsb. Catching Exceptions>>c. Taking appriopriate actionsd. All of the above>> or135) When we implement the runnable interface we must define the methoda. start()b. init()c. run() >>d. runnable()136) What can interfaces contain?a. Methods>>b. Variablesc. classesd. Both 1 & 2137) What will be displayed as output if S1 contains word "Java" with method

    S1.indexOf('a',3)

    a. 4b. 2>>c. 1d. 3

    138) How is it possible to make it compulsory that a method is redefined in a subclassa. By making a class privateb. By making a class abstractc. By making the class final

  • 7/23/2019 Solved Java

    22/28

    d. By making the class virtual>>139) When default keyword is used a member of a class, how is the visiblility of the

    member

    a. It is visible everywhereb. It is visible everywhere in the current package and also subclasses in other packagesc. It is visible everywhere in the current package onlyd. It is visible only in its own class>>140) Which of the following portion specified in the for loop is compulsarya. Initializationb. test condition>>c. Incrementd. All of the above>> its only for FOR LOOP141) What line numbers will cause an error when you compile this code// 6,7,12

    1 class chknum

    2 {

    3 public static void main(String args[])

    4 {5 int n=3;

    6 switch(n);

    7 {

    8 case 0 :System.out.print(No is 0);

    9 case 1 :System.out.print(No is 1);

    10 case 2 :System.out.print(No is 2);

    11 case 3 :System.out.print(No is 3);

    12 case 3 :System.out.print(Other Number);break;

    13 } } }

    a. Lines 3,7,8,9,10,11b. Lines 6,8,9,10,11,12>>c. Lines 7,10,11d. Lines 11,12142) Which of the following is True with respect to branching statements if & switcha. every if statement can be written using switch>>b. every case must end with a break statementc. every case label follows with a(:) colon--------------143) What is the value of the expression abs(1)//a. 1>>b. -1c. 0d. 11

    144) How many arguments does the pow math function requirea. 0b. 1c. 2 >> or mored. 3

    145) What is process of converting one data type to anothera. Convertingb. Changingc. Defining

  • 7/23/2019 Solved Java

    23/28

    d. Casting >>146) To print string on the screen we use System.out.println. What is the correct

    explaination for this

    a. System is a class.println is a method and out is a object >>b. System is a Object.out is a object and println is data memberc. System is a package out is a method print is a objectd. System is a pointer to object out of class println147) In, Java Exception handling code what could be done in the finally blocka. It is used to write initialization codeb. It can be used to perform house-keeping operationsc. It can be used to catch all exceptionsd. It can be used to ignore all exceptions>>

    148) In Multithreaded programming, which of the following method is used to changethe priority of a Thread

    a. changePrior()b. setPrior()c. setPriority()>>d. ThreadPrior()149) Which of the following is possible using Vector class//a. It is used to store objectsb. It can store objects that may vary in sizec. It is possible to add & deleted. All of Three>>

    150) The concept of inheritance is implemented in Java bya. creating more than one classb. extending two or more classes SA>>c. extending one class and implementing one or more interfacesd. importing classes from packages151) Which of the following keywords cannot be used to control access to a class

    member

    a. Interfaceb. Abstract>>c. Publicd. Protected

    152) What will be the output of the following code segmentn=5;

    r=n%3;

    if (r == 0)

    System.out.println(zero);

    else

    if (r ==1)

    System.out.println(one);

    elseif (r == 2)

    System.out.println(two);

    else

    System.out.println(three);

  • 7/23/2019 Solved Java

    24/28

    a. zerob. Onec. Two>>d. Three153) In the switch statement the constant expression that is checked can be of typea. Character>>b. floatc. Byted. Short

    154) An expression having variables of type byte,short,int and long then what type ofthe variable will be the resultvariable

    a. int >>b. longc. Shortd. Byte155) Which of the following is a primitive Data type in Javaa. Character>>b. Classesc. Arraysd. Interface156) Which of the following is NOT a valid documentation comment used in Javaa. //b. \\c. /* */d. /** */>>157) Which of the following feature in C is NOT included in Javaa. Break statementb. Continue statementc. Pointer type>>d. Primitive data types158) Identify line numbers where errors occur in the following code

    1 class sample

    2 {

    3 public static void main(String[], args[])>>

    4 {

    5 System.out.println(Hello);6 }

    7 };a. Lines 3,7 >>b. Line 3c. Line 7d. Line 5

    159) Identify line numbers where errors occur in the following code 1,3,6,81 Class sample

    2 {

    3 public static void main(string args[])

    4 {

    5 int m=10;

    6 {

  • 7/23/2019 Solved Java

    25/28

    7 int m=20;

    8 }

    9 }

    10 }

    a. Lines 1,3,7 >>b. Line 3,5,7>>c. Line 5,7d. Line 3,5

    160) Identify line numbers where compile errors occur in the following code1 class sample

    2 {

    3 public static void display()

    4 {

    5 byte x=212;

    6 float f=100.12;

    7 System.out.println("Value of f="+f);

    8 System.out.println("Value of x="+x);

    9 }10 }

    a. Lines 5,6,7,8b. Line 5,6>>c. Line 7,8d. Line 5,6

    161) What will be the output of the following code segmentint m = 100;

    int n =103;

    while(++m>b. 101c. 103d. 100

    162) What will be happen when the following code is executed.class check

    {

    public static void main(String args[])

    {

    int m;

    System.out.print(m is +m);

    }

    }a. Run-time errorb. Compile-time error>>c. m is 0d. No output

  • 7/23/2019 Solved Java

    26/28

    163) What will be the output of the following code, if executed with command line argumentsas follows

    javacmdline Java is wonderful

    classcmdline

    {public static void main(String args[])

    {

    System.out.println(Number of arguments : +args.length);

    for(inti=0;i>140

    165) What is the output of the following program codeclass check

    {

    public static void main(String args[])

    {

    boolean b=true;

    if(b)System.out.println("False");

    System.out.println("True");

    return;

    }

    }

    a. Trueb. Falsec. False True>>d. Error166) class sample

    {

    public static void main(String args [])

    {

    int x=10;

  • 7/23/2019 Solved Java

    27/28

    int y=15;

    system.out.print(x>y?4:3)

    }

    }

    a) 3>>b) 4c) 10d)

    15

    167) What is the result if the code of statements are executedclassswtest

    {

    public static void main(String args[])

    {

    char ch=i;

    switch(ch)

    {

    case a :

    case e :

    case i : System.out.println(It is a vowel);

    case o :

    case u : System.out.println(It is a vowel);break;

    default :System.out.println(It is a consonant);

    }

    }

    }a)No outputb) It is a vowelc)It is a consonantd) It is a vowel>>

    168) What will be the output of the following code segmentint r=100;

    while(true)

    {

    if(r>b) r is 10c) r is 100d) r is -10

    169) [20] Java is a _________ Languagea. Compiledb. Interpretedc. Both Compiled and Interpreted>>d. Byte Code170) Java is Platform-independent, What statement explain this featurea. Java programs can be easily moved from one computer system to another>>

  • 7/23/2019 Solved Java

    28/28

    b. Java systems verify memory access and virusc. Java can be used to create applications on the networksd. It provides many safeguards to ensure reliable code171) Java is Robust, What statement explain this featurea. Java programs can be easily moved from one computer system to anotherb. Java systems verify memory access and virusc. Java can be used to create applications on the networksd. It provides many safeguards to ensure reliable code>>172) What was Java originally called asa. Object Cb. Object Basicc. Oak>>d. Pascal