☕ Java Programming MCQs and Exam Questions

Practice 80 approved ☕ Java Programming MCQs and exam questions from the 💻 Programming subject.

80 solved MCQs

Which one of these lists contains only Java programming language keywords?Answer: goto, instanceof, native, finally, default, throws Which will legally declare, construct, and initialize an array?Answer: int myList [] = {4, 3, 7}; Which is a reserved word in the Java programming language?Answer: native Which is a valid keyword in java?Answer: interface Which three are legal array declarations? 1. int [] myScores []; 2. char [] myChars; 3. int [6] myScores; 4. Dog myDogs []; 5. Dog myDogs [7];Answer: 1, 2, 4 Which one of the following will declare an array and initialize it with five numbers?Answer: int [] a = {23,22,21,20,19}; Which three are valid declarations of a char? 1. char c1 = 064770; 2. char c2 = 'face'; 3. char c3 = 0xbeef; 4. char c4 = \u0022; 5. char c5 = '\iface'; 6. char c6 = '\uface';Answer: 1, 3, 6 Which is the valid declarations within an interface definition?Answer: public double methoda(); Which one is a valid declaration of a boolean?Answer: boolean b3 = false; Which three are valid declarations of a float? 1. float f1 = -343; 2. float f2 = 3.14; 3. float f3 = 0x12345; 4. float f4 = 42e7; 5. float f5 = 2001.0D; 6. float f6 = 2.81F;Answer: 1, 3, 6 Which is a valid declarations of a String?Answer: String s1 = null; What is the numerical range of a char?Answer: 0 to 65535 Java applets are developed in ______?Answer: Java language Which of the following statements is true about an interface in Java?Answer: It can have abstract methods and default methods Who invented Java programming?Answer: James Gosling PHP syntax is closed withAnswer: Java and C++ Snapchat is owned byAnswer: Sanp lnc How many decisions can be handled using if-else-else?Answer: As many as need What is the space complexity of the merge sort algorithm?Answer: O(n) Which programming language is known for its use in web development?Answer: JavaScript