The first line of a constructor declaration is line C, which is "public try_ques(int players, int stage)".
An enum type can define constructors and implement interfaces.
The valid method declaration is "void func() {/* ... */}".
The output of the given code will be 66.
The output of the float calculation code will be 1.5.
Download as DOCX, PDF, TXT or read online on Scribd
0 ratings0% found this document useful (0 votes)
101 views
Java Sample Questions
The first line of a constructor declaration is line C, which is "public try_ques(int players, int stage)".
An enum type can define constructors and implement interfaces.
The valid method declaration is "void func() {/* ... */}".
The output of the given code will be 66.
The output of the float calculation code will be 1.5.
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1
answer
questionStatement answerA answerB answerC D
Identify the first line of a constructor declaration in the following code? public class try_ques { // A int current, step; public void cart(int strength) { strength = strength + 1 ;//B } public try_ques(int players, int stage) // C { setCurrent(players,stage); } public void setCurrent(int value,int value2) { current=value; step=value2; }// D } A B C D Objects of class two have a field Given the following code, which statements are true? Class named Class two None of One { private int one_value; } class two extends one { int one_valu extends Both A and the two_value; } e. class one. B. above. void func int func() boolean func(voi Which one of these declarations is a valid method {/* ... {/* ... func(void) d) {/* declaration? */} */} {/* ... */} ... */} It allows sequential An enum access to type can all the An enum impleme elements type can nt stored in define All of interface the constructor the Which of the following is true about enumumerations? s. collection. s. above. int int i[]=new int i=new int i=new i[]=new Which of the following is a valid statement? int[1]; int; int(); int(); Which of the following statements is wrong? public class ques { // A public static void main (String[] args) { int i=0; final int b=0; int c=0;//1 i=i++;//2 b=b+ +;//3 c=c++;//4 } } 1 2 3 4 Which of the following is not a reserved keyword? public static void main What will the output of the following code: public class try_ques { // A public static void main(String[] args) { None of int b=0; try { char c='B'; b=(int)c; } finally { Compilati the System.out.println(b); } } } 66 on error 0 above What will be the output of the following code? public class try_ques { public static void main(String[] args) { float i=(float)(1/2 + 3/2 + 0.1); System.out.println(i); } } 1.1 1 2 1.5 The subclass Every of a non- Java abstract object A class class can has a can only be public extend declared A final class method one as can be named Which of the following is not true in Java? class. abstract. abstract. length.