software dev final

Réussis tes devoirs et examens dès maintenant avec Quizwiz!

What is the extension of compiled java classes? a) .txt b) .js c) .class d) .java

C

What is the output of the following Java program? class One{ public One(){ System.out.print("One,"); } } class Two extends One{ public Two(){ System.out.print("Two,"); } } class Three extends Two{ public Three(){ System.out.print("Three"); } } public class Test{ public static void main(String[] args){ Three three = new Three(); } } a) Three b) One c) One,Two,Three d) Run-time error

C

What will be the output of the following Java program? public class StrEqual { public static void main(String[] args) { String s1 = "hello"; String s2 = new String("hello"); String s3 = "hello"; if (s1 == s2) { System.out.println("s1 and s2 equal"); } else { System.out.println("s1 and s2 not equal"); } if (s1 == s3) { System.out.println("s1 and s3 equal"); } else { System.out.println("s1 and s3 not equal"); } } } Which one of the following options provides the output of this program when executed? a) s1 and s2 equal s1 and s3 equal b) s1 and s2 equal s1 and s3 not equal c) s1 and s2 not equal s1 and s3 equal d) s1 and s2 not equal s1 and s3 not equal

C

Which of these cannot be used for a variable name in Java? a) identifier & keyword b) identifier c) keyword d) none of the mentioned

C

Which of these keywords is used to define interfaces in Java? a) intf b) Intf c) interface d) Interface

C

What will be the output of the following Java program? class Output { public static void main(String args[]) { double x = 2.0; double y = 3.0; double z = Math.pow( x, y ); System.out.print(z); } } a) 9.0 b) 8.0 c) 4.0 d) 2.0

B

Which exception is thrown when java is out of memory? a) MemoryError b) OutOfMemoryError c) MemoryOutOfBoundsException d) MemoryFullException

B

Which of the following is a type of polymorphism in Java Programming? a) Multiple polymorphism b) Compile time polymorphism c) Multilevel polymorphism d) Execution time polymorphism

B

Who invented Java Programming? a) Guido van Rossum b) James Gosling c) Dennis Ritchie d) Bjarne Stroustrup

B

compareTo() returns A. True B. False C. An int value D. None

C

Find the output of the following code. if(1 + 1 + 1 + 1 + 1 == 5){ System.out.print("TRUE"); } else{ System.out.print("FALSE"); } A. TRUE B. FALSE C. Compile error D. None

A

Find the output of the following program. public class Solution{ public static void main(String[] args){ byte x = 127; x++; x++; System.out.print(x); } } A. -127 B. 127 C. 129 D. 2

A

In which of the following is toString() method defined? A. java.lang.Object B. java.lang.String C. java.lang.util D. None

A

To which of the following does the class string belong to. A. java.lang B. java.awt C. java.applet D. java.string

A

What is the output of the following Java program? class Demo{ public Demo(int i){ System.out.println("int"); } public void Demo(short s){ System.out.println("short"); } } public class Test{ public static void main(String[] args){ short s = 10; Demo demo = new Demo(s); } } a) int b) short c) Compile-time error d) Run-time error

A

What is the output of the following Java program? class One{ public void print(){ System.out.println("1"); } } class Two extends One{ public void print(){ System.out.println("2"); } } public class Test{ public static void main(String args[]){ One one = new Two(); one.print(); } } a) 2 b) 1 c) Compile-time error d) Run-time error

A

What is the output of the following Java program? public class Main{ public static void main(String []args){ for (int i = 0; i < 5; i++) { System.out.print(i + " "); if (i == 2) break; } } } a) 0 1 2 b) 0 1 2 3 4 c) 0 1 d) 0 1 2 3 4 5

A

Which one of the following is not a Java feature? a) Object-oriented b) Use of pointers c) Portable d) Dynamic and Extensible

B

Find the output of the following program. public class Solution{ public static void main(String[] args){ short x = 10; x = x * 5; System.out.print(x); } } A. 50 B. 10 C. Compile error D. Exception

C

Identify the corrected definition of a package. A. A package is a collection of editing tools B. A package is a collection of classes C. A package is a collection of classes and interfaces D. A package is a collection of interfaces

C

Identify the output of the following program. Public class Test{ Public static void main(String argos[]){ String str1 = "one"; String str2 = "two"; System.out.println(str1.concat(str2)); } } A. one B. two C. onetwo D. twoone

C

Number of primitive data types in Java are? A. 6 B. 7 C. 8 D. 9

C

Total constructor string class have? A. 3 B. 7 C. 13 D. 20

C

What is the output of the following Java program? class Parent{ public void className(){ System.out.println("Parent"); } } class Child extends Parent{ void className(){ System.out.println("Child"); } } public class Test{ public static void main(String[] args){ Parent parent = new Child(); parent.className(); } } a) Parent b) Child c) Compile-time error d) Run-time error

C

What will be the output of the following Java code? class Output { public static void main(String args[]) { Integer i = new Integer(257); byte x = i.byteValue(); System.out.print(x); } } a) 257 b) 256 c) 1 d) 0

C

What will be the output of the following Java code? class box { int width; int height; int length; } class main { public static void main(String args[]) { box obj = new box(); obj.width = 10; obj.height = 2; obj.length = 10; int y = obj.width * obj.height * obj.length; System.out.print(y); } } a) 100 b) 400 c) 200 d) 12

C

What will be the output of the following Java program? class leftshift_operator { public static void main(String args[]) { byte x = 64; int i; byte y; i = x << 2; y = (byte) (x << 2); System.out.print(i + " " + y); } } a) 0 256 b) 0 64 c) 256 0 d) 64 0

C

Which component is used to compile, debug and execute the java programs? a) JRE b) JIT c) JDK d) JVM

C

Which of the following is a superclass of every class in Java? a) ArrayList b) Abstract class c) Object class d) String

C

Which of the following is not an OOPS concept in Java? a) Polymorphism b) Inheritance c) Compilation d) Encapsulation

C

Find the output of the following code. Public class Solution{ Public static void main(String... argos){ Int x = 5; x * = (3 + 7); System.out.println(x); A. 50 B. 22 C. 10 D. None

A

What is the output of the following Java program? public class Main{ public static void main(String []args){ int i = 0; do { System.out.print(i + " "); i++; } while (i < 5); } } a) 0 1 2 3 4 b) 0 1 2 3 4 5 c) 1 2 3 4 5 d) The code will not compile due to a syntax error.

A

What is the output of the following Java program? public class Main{ public static void main(String []args){ int x = 10; int y = 5; int z = (x > y) ? x : y; System.out.println(z); } } a) 10 b) 5 c) 15 d) The code will not compile due to a syntax error.

A

What is the output of the following Java program? public class Main{ public static void main(String []args){ int x = 10; while (x > 0) { System.out.print(x + " "); x--; } } } a) 10 9 8 7 6 5 4 3 2 1 b) 10 9 8 7 6 5 4 3 2 1 0 c) 1 2 3 4 5 6 7 8 9 10 d) The code will not compile due to a syntax error.

A

What is the output of the following Java program? public class Main{ public static void main(String []args){ int x = 5; int y = 10; if (x < y) System.out.println("x is less than y"); else if (x > y) System.out.println("x is greater than y"); else System.out.println("x is equal to y"); } } a) x is less than y b) x is greater than y c) x is equal to y d) The code will not compile due to a syntax error.

A

What is the output of the following code snippet? import java.util.regex.*; public class RegexQuiz { public static void main(String[] args) { String regex = "[a-c]"; String input = "abcABC"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(input); while (matcher.find()) { System.out.print(matcher.group() + " "); } } } a) a b c b) A B C c) a b c A B C d) Compile-time error

A

What is the output of the following code snippet? int x = 5; int y = 10; System.out.println(x + y + "Hello"); a) 15Hello b) Hello15 c) 510Hello d) 5Hello10

A

What is the output of the following code snippet? public class Main { public static void main(String[] args) { String str = "Java"; str.concat(" Programming"); System.out.println(str); } } a) Java b) Java Programming c) Programming d) Compile-time error

A

What is the output of the following program? public class Main { public static void main(String[] args) { int x = 10; int y = x++; System.out.println(y); } } a) 10 b) 11 c) 9 d) Compile-time error

A

What is the size of float and double in java? A. 32 and 64 B. 32 and 32 C. 64 and 64 D. 64 and 32

A

What will be the output of the following Java code snippet? class abc { public static void main(String args[]) { if(args.length>0) System.out.println(args.length); } } a) The snippet compiles and runs but does not print anything b) The snippet compiles, runs and prints 0 c) The snippet compiles, runs and prints 1 d) The snippet does not compile

A

What will be the output of the following Java code? class String_demo { public static void main(String args[]) { char chars[] = {'a', 'b', 'c'}; String s = new String(chars); System.out.println(s); } } a) abc b) a c) b d) c

A

What will be the output of the following Java code? class increment { public static void main(String args[]) { int g = 3; System.out.print(++g * 8); } } a) 32 b) 33 c) 24 d) 25

A

What will be the output of the following Java program? class recursion { int func (int n) { int result; if (n == 1) return 1; result = func (n - 1); return result; } } class Output { public static void main(String args[]) { recursion obj = new recursion() ; System.out.print(obj.func(5)); } } a) 1 b) 120 c) 0 d) None of the mentioned

A

What will be the output of the following Java program? class variable_scope { public static void main(String args[]) { int x; x = 5; { int y = 6; System.out.print(x + " " + y); } System.out.println(x + " " + y); } } a) Compilation error b) Runtime error c) 5 6 5 6 d) 5 6 5

A

What will be the output of the following Java program? class Base { public Base() { System.out.println("Base"); } } class Derived extends Base { public Derived() { System.out.println("Derived"); } } class DeriDerived extends Derived { public DeriDerived() { System.out.println("DeriDerived"); } } public class Test { public static void main(String[] args) { Derived b = new DeriDerived(); } } a) Base Derived DeriDerived b) Derived DeriDerived c) DeriDerived Derived Base d) DeriDerived Derived

A

What will be the output of the following program? class First { static void staticMethod() { System.out.println("Static Method"); } } public class MainClass { public static void main(String[] args) { First first = null; first.staticMethod(); } } a) Static Method b) Throws a NullPointerException c) Compile-time error d) Runtime error

A

When an array is passed to a method, what does the method receive? A. The reference of the array B. A copy of the array C. Length of the array D. Copy of first element

A

When is the object created with new keyword? A. At run time B. At compile time C. Depends on the code D. None

A

Arrays in java are- A. Object references B. objects C. Primitive data type D. None

B

Automatic type conversion is possible in which of the possible cases? A. Byte to int B. Int to long C. Long to int D. Short to int

B

Find the output of the following code. int ++a = 100; System.out.println(++a); A. 101 B. Compile error as ++a is not valid identifier C. 100 D. None

B

Find the output of the following program. public class Solution{ public static void main(String[] args){ int[] x = {120, 200, 016}; for(int i = 0; i < x.length; i++){ System.out.print(x[i] + " "); } } } A. 120 200 016 B. 120 200 14 C. 120 200 16 D. None

B

Find the value of A[1] after execution of the following program. int[] A = {0,2,4,1,3}; for(int i = 0; i < a.length; i++){ a[i] = a[(a[i] + 3) % a.length]; } A. 0 B. 1 C. 2 D. 3

B

How many objects will be created in the following? String a = new String("Interviewbit"); String b = new String("Interviewbit"); Strinc c = "Interviewbit"; String d = "Interviewbit"; A. 2 B. 3 C. 4 D. None

B

Identify the keyword among the following that makes a variable belong to a class, rather than being defined for each instance of the class. A. final B. static C. volatile D. abstract

B

Identify the output of the following program. String str = "abcde"; System.out.println(str.substring(1, 3)); A. abc B. bc C. bcd D. cd

B

Identify the return type of a method that does not return any value. A. int B. void C. double D. None

B

Identify what can directly access and change the value of the variable res. Package com.mypackage; Public class Solution{ Private int res = 100; } A. Any class B. Only Solution class C. Any class that extends Solution D. None

B

Select the valid statement to declare and initialize an array. A. int[] A = {} B. int[] A = {1, 2, 3} C. int[] A = (1, 2, 3) D. int[][] A = {1,2,3}

B

Select the valid statement. A. char[] ch = new char(5) B. char[] ch = new char[5] C. char[] ch = new char() D. char[] ch = new char[]

B

What does the following string do to given string str1. String str1 = "Interviewbit".replace('e','s'); A. Replaces single occurrence of 'e' to 's'. B. Replaces all occurrences of 'e' to 's'. C. Replaces single occurrence of 's' to 'e'. D. None.

B

What is Truncation in Java? a) Floating-point value assigned to a Floating type b) Floating-point value assigned to an integer type c) Integer value assigned to floating type d) Integer value assigned to floating type

B

What is not the use of "this" keyword in Java? a) Referring to the instance variable when a local variable has the same name b) Passing itself to the method of the same class c) Passing itself to another method d) Calling another constructor in constructor chaining

B

What is the output of the following Java program? class Demo{ void Demo(){ System.out.println("Demo"); } } public class Test{ public static void main(String[] args){ Demo demo = new Demo(); } } a) Demo b) No Output c) Compile-time error d) Run-time error

B

What is the output of the following Java program? class Hello{ public Hello(){ System.out.println("Hello"); } } public class Main{ Hello hello = new Hello(); public static void main(String[] args) { System.out.println("Hello World!"); } } a) Hello b) Hello World! c) No Output d) Run-time error

B

What is the output of the following Java program? class One{ public One(int x){ System.out.print("int constructor"); } public One(long l){ System.out.print("long constructor"); } } public class Test{ public static void main(String[] args){ long l = 20L; One one = new One(l); } } a) int constructor b) long constructor c) Compile-time error d) Run-time error

B

What is the output of the following Java program? class One{ public static void print(){ System.out.println("1"); } } class Two extends One{ public static void print(){ System.out.println("2"); } } public class Test{ public static void main(String args[]){ One one = new Two(); one.print(); } } a) 2 b) 1 c) Compile-time error d) Run-time error

B

What is the output of the following Java program? public class Main{ public static void main(String []args){ for (int i = 0; i < 5; i++) { if (i == 2) continue; System.out.print(i + " "); } } } a) 0 1 2 3 4 b) 0 1 3 4 c) 2 d) 0 1 3 4 5

B

What is the output of the following Java program? public class Main{ static String name = "Ramesh"; public Main(){ name = "Prabhas"; } public static void main(String[] args){ System.out.println("The name is " + name); } } a) Prabhas b) The name is Ramesh c) No Output d) Run-time error

B

What is the output of the following Java program? public class Test { public static void main(String[] args) { String s1 = "hello"; String s2 = new String("hello"); s2 = s2.intern(); System.out.println(s1 == s2); } } a) false b) true

B

What is the output of the following code snippet? import java.util.regex.*; public class RegexQuiz { public static void main(String[] args) { String regex = "\\d+"; String input = "1234"; Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(input); while (matcher.find()) { System.out.print(matcher.group() + " "); } } } a) 1 b) 1234 c) 123456789 d) Compile-time error

B

What is the output of the following code snippet? public class Main{ public static void main(String []args){ String str1 = "Hello"; String str2 = new String("Hello"); System.out.println(str1 == str2); } } a) true b) false c) It will cause a compilation error. d) It will throw a runtime exception.

B

Identify the correct restriction on static methods. I. They must access only static data II. They can only call other static methods. III. They cannot refer to this or super. A. I and II V. II and III C. Only III D. I, II and III

D

Identify the output of the following program. String str = "Hellow"; System.out.println(str.indexOf('t)); A. 0 B. 1 C. true D. -1

D

What is the extension of java code files? a) .js b) .txt c) .class d) .java

D

What is the output of the following code snippet? int[] arr = {1, 2, 3, 4, 5}; System.out.println(arr.length); a) 1 b) 2 c) 3 d) 5

D

What is the output of the following code? ___ int Integer = 24; char String = 'I'; System.out.print(Integer); System.out.print(String); ___ A. Compile error B. Throws exception C. I D. 24 I

D

What will be the error in the following Java code? byte b = 50; b = b * 50; a) b cannot contain value 50 b) b cannot contain value 100, limited by its range c) No error in this code d) * operator has converted b * 50 into int, which can not be converted to byte without casting

D

What will be the output of the following Java code? class output { public static void main(String args[]) { String c = "Hello i love java"; boolean var; var = c.startsWith("hello"); System.out.println(var); } } a) 0 b) true c) 1 d) false

D

What will be the output of the following Java program? class Output { public static void main(String args[]) { int arr[] = {1, 2, 3, 4, 5}; for ( int i = 0; i < arr.length - 2; ++i) System.out.println(arr[i] + " "); } } a) 1 2 3 4 5 b) 1 2 3 4 c) 1 2 d) 1 2 3

D

What will be the output of the following Java program? class output { public static void main(String args[]) { StringBuffer s1 = new StringBuffer("Quiz"); StringBuffer s2 = s1.reverse(); System.out.println(s2); } } a) QuizziuQ b) ziuQQuiz c) Quiz d) ziuQ

D

What will be the output of the following Java program? class output { public static void main(String args[]) { double a, b,c; a = 3.0/0; b = 0/4.0; c=0/0.0; System.out.println(a); System.out.println(b); System.out.println(c); } } a) NaN b) Infinity c) 0.0 d) all of the mentioned

D

What will be the output of the following Java program? public class Test { public void print(Integer i) { System.out.println("Integer"); } public void print(int i) { System.out.println("int"); } public void print(long i) { System.out.println("long"); } public static void main(String args[]) { Test test = new Test(); test.print(10); } } a) The program results in a compiler error ("ambiguous overload"). b) long c) Integer d) int

D

Which environment variable is used to set the java path? a) MAVEN_Path b) JavaPATH c) JAVA d) JAVA_HOME

D

Which of these are selection statements in Java? a) break b) continue c) for() d) if()

D

Which statement is true about Java? a) Java is a sequence-dependent programming language b) Java is a code dependent programming language c) Java is a platform-dependent programming language d) Java is a platform-independent programming language

D


Ensembles d'études connexes

AGM 2210 Surveying Earthwork and Land Area Measurements

View Set

NR 206 Assessing Male Genitalia and Rectum

View Set

Network+_Chapter 4,6,7,8,9,10,10_MASTER DUMP

View Set

AUT 125 - Chapter 21 Coolant System Operation and Diagnosis

View Set

Fluid Volume Excess (Overload)/Hypervolemia

View Set

AC Sys, Lvl I - Lesson 2: Understanding Vectors and How to Use Them Effectively

View Set

Physical Science (PSY151) Chapter 7: Les Thomas

View Set

[Exam 3] Pearson Questions: Ch. 10, 11, 12, 14 [MKT 381]

View Set

Nutrition Chapter 6 Fats Cengage

View Set