Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 2

Q1. Look at this series: 7, 10, 8, 11, 9, 12, … What number should come next?

A. 7
B. 12
C. 10
D. 13
Ans : 10

Q2. Which word does NOT belong with the others?


A. wing
B. fin
C. beak
D. rudder
Ans : Beak

Q3. Safe : Secure :: Protect :


A. Lock
B. Guard-
C. Sure
D. Conserve
Ans : Guard

Q4. How do you print the first non-repeated character from a string?
Ans:

Q5. How do you count a number of vowels and consonants in a given string?
Ans :

import java.util.*;
public class Count{
public static void main(String args[]){

Scanner in=new Scanner(System.in);


int vowel=0;
int conso=0;

System.out.println("Enter String : ");


String s=in.nextLine();

for(int i=0;i<s.length();i++){
if(s.charAt(i)=='a' || s.charAt(i)=='e' || s.charAt(i)=='i' ||
s.charAt(i)=='o' || s.charAt(i)=='u'){
vowel++;
}
else if(s.charAt(i) >= 'a' && s.charAt(i)<='z'){
conso++;
}
}
System.out.println("vowels "+ vowel);
System.out.println("consonant : "+ conso);
}
}

Q6. Enlist some commands of DDL, DML, and DCL.


Ans :
DDL Command :

CREATE TABLE TABLENAME(COLUMNNAME DATATYPE(SIZE),.......);


DROP TABLE TABLENAME;

ALTER TABLE TABLENAME ADD(COLUMNAME DATATYPE(SIZE));

DML Command :

INSERT INTO TABLENAME VALUES(VAL1,VAL2,VAL3,...);

UPDATE TABLENAME SET COLUMNNAME=VALUE;

DELETE FROM TABLENAME WHERE CONDITION;

DCL Command :

GRANT CREATE TABLE TO USERNAME;


REVOKE CREATE TABLE FROM USERNAME;

You might also like